Saturday 15 September 2012

Creating batch file to execute your jar file

After you are done with your project you want it to put online i.e. you want to publish your software which you made to make sure it is used by some end users and believe me, its a good thought and the project developer will have a different feeling :) .For that you would like to create a set up for your software. There are many softwares available in market which allow you to create set up of your project from your .jar file. But most of it will not work accordingly or understanding it is a bit difficult task.
I will provide a step-by-step solution for creating a set up for your project in my next post in this category.
For now we will learn how to create a batch file to execute your executable jar file on one click.

Here is an example:

set classpath=D:\dist\lib\swt-3.7M5-win32-win32-x86.jar;
java -jar D:\dist\AcmeReader.jar
pause


1.In the first line you have to set the classpath to all the dependent .jar files separated with semicolon.
2.The second line executes the main .jar file of your project.
3.The third line makes your command prompt to pause so that you can see the output or errors if any which will be displayed on command prompt.

thats it...save it with "filename.bat" .Remember the .bat extension.
U r done :)
Double Click the .bat file to execute your .jar file from here.
Enjoy!! :)

Any queries regarding setting up the classpath or other doubts and comments are always welcome :) :)

0 comments:

Post a Comment