When You Write your code and you want it to create one executable file for easy to share and Run your Code Creating a Jar File is the best Option for you as a developer.
For IntelliJ
1. In IntelliJ You go the right side of the maven Icon (M) open it.
2. On opening You Identify your project there, You can expand it by click on the > icon
3. Expand the Lifecycle then double click on the package icon
4. and the magic will start and you will see that It will create a jar file for you !
For STS
1. Open your project in STS
2. Go to The Run As
3 . Maven Build the second one (Maven Build )
4. On Goal give as package
5. And The Jar file will be created For you with an Ease !
How To Run Your JAR
1. Copy your Jar and take it to a New Folder
2. Open your New Folder where you paste your Jar File
3. Open the Command Prompt by cmd on the path by typing [cmd] hit Enter
4. then run the jar file by command java -jar yourjarfile.jar
5. Now it is started You can test with your frontend technology (I use React and It’s working Just WOW!)
- From below you are able to download the Jar file in Zip format
- After download unzip the file using [7zip] or [WinRaR] and run it in command prompt
* Note : In your system download and install the java 17 JDK or the above to run any java code .
- Download IntelliJ IDE
- Here is One Example from Start to End Setup
Download the IntelliJ IDE Community Edition for Free
2. Create Your Spring boot appliation using Spring Initializer
3. Allow The access
4. If This Project JDK is not defined showing then Click on Setup SDK and Select 17 if You Have else Download JDK It will Automatically Download and Setup for You. If not showing Just skip This part .
5. On the Top of Notification below You find your Maven ICON Click on it
6. Go to the Lifecycle of your project and double Click on the package
7. Your Jar file will start creating now
8. Find your Jar file in your target location use Ctrl + Click to go there then open in explorer.
- Test the jar file by opening the location on the Command Prompt then run the jar file with this command : java -jar TestAppv1-0.0.1-SNAPSHOT.jar
open command prompt on the location where your jar file is exist . eg. ..\TestAppv1\TestAppv1\target>
Tips:
My Personal Choice That I use for Spring Boot application or any Java Project is The IntelliJ IDE Free Community Edition
Example of Run the above Jar file or Program for printing the star pattern