Run jar file from bat file

You need a executable jar file. See how to create a jar file

or

Get the demo jar

Once your jar file is ready.

Step 1: Create a bat file with any name.

Step 2: Write the following line in you bat file.

If you want to hold the black screen. Use the following code

Now run the bat file and it will start you jar file

Main Class

How to create an executable jar file using eclipse

You can do this by using eclipse.

Step 1: Create a project. I have created a project with name “autorun”

Step 2: Right click on project > select Export
You will see export options select JAR file, then click next

jar export
 
Step 3:
Select the resource to export. Give export destination.

jar file specification
 
Step 4: Click Next.

Step 5: Specify the “main class” that you want to execute when someone clicks on the jar file (it is a starting point) , then Click Finish

Main Class

Done. Now Double click on the jar and it will run.