I am created jar file.The jar file is an executable one.But how can i run the jar file from the out side,using created batch file.I want to know the batch file coding to run the jar file without mentioning class path. Or is there any way to do it?
A:
If double-clicking the .jar file in Windows Explorer works, then you should be able to use this:
start myapp.jar
in your batch file.
The Windows start
command does exactly the same thing behind the scenes as double-clicking a file.
RichieHindle
2010-04-12 12:40:22
It gives the error windows cannot find myapp.jar(my jar file).
Arivu2020
2010-04-13 05:52:58
@Arivu2020: Are you in the right directory? Perhaps your batch file need to do `cd c:\path\to\my\stuff` before trying to run the jar file?
RichieHindle
2010-04-13 08:41:05
A:
Just the same way as you would do in command console. Copy exactly those commands in the batch file.
BalusC
2010-04-12 12:41:30
A:
To run a .jar
file from the command line, just use:
java -jar YourJar.jar
To do this as a batch file, simply copy the command to a text file and save it as a .bat
:
@echo off
java -jar YourJar.jar
The @echo off
just ensures that the second command is not printed.
mdm
2010-04-12 12:41:41
@Carlos: I assumed that as the OP asked for a batch file, that they were using Windows.
mdm
2010-04-12 14:20:55
I am using windows 7.I have the jar file in the D:\my.jarI write the following code in my batch file@echo offjava -jar my.jar and also i tried@echo offjava -jar D:\my.jarwhat can i do?
Arivu2020
2010-04-13 10:54:14
+1
A:
If you want a batch file to run a jar file, make a blank file called runjava.bat with the contents:
java -jar "C:\myjarfile.jar"
Jonno_FTW
2010-04-12 12:42:06