run the JAVA application JAR file in Java code

For this purpose the following process we have to follow

1 : First time to create one executable jar file .

2: Java code to run this executable JAR file

let me explain

first we have to create one Java application with the help of the eclipse.

  1. create a package
  2. create a class , in this class. the main method we have to create one simple statement. with the help of this statement we have to print hello world

run this application.

Now create an executable JAR file.

Save this JAR file in any location

check this JAR file by double clicking if everything is working no problem.

To run this executable JAR file first we have to create one batch file batch file consisting of the following

cd F:\TheProgrammersBook\July_20_2019\RunnableJar
java -jar FirstRunnableJar.jar

The following is the Application structure.

The following is the Code to Run Jar file structure.

Jar file and bat file saving location.

Execution process:

Go to thee file and run this file .. then the Runnable jar file :FirstRunnableJar.jar file will be run and the output will be as follows.

The full source code of our examples here is, as always, over on GitHub.

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *