I had written a program:
public class SystemShutdown {
public static void main(String[] args) {
try{
for(int i=0;i<10;i++){
Thread.sleep(1000);
}
Process p=Runtime.getRuntime().exec("shutdown -s -t 2700");
}catch(Exception e){}
}
}
I’d compiled and kept the .class file separate.
Now, I’d write a manifest file as:
Manifest-Version: 1.0
Main-Class: SystemShutdown
And saved with the name MANIFEST.MF
I’d put both (the .class file and the MANIFEST.MF file) in same directory.
Now I want to create an Executable Jar file. For that I’d done:
jar cvfm MyJar.jar *.*
A jar file is created after that.
But when I tries to execute it displays a message Java Exception occured.
Can anybody help me out?
I want to execute this program on the users double click.
Beside of the above scratch can anybody tell me the exact steps to be followed to create an executable jar?
I’m using Windows7 32bit and jdk7
The
moption of the command line forjarsays you’ll provide the manifest file as the following parameter (in this case, after the jar file itself). So I suspect you want:See the jar tool documentation for more details.
EDIT: I’ve just tried this and it works fine. Code:
Command line and output:
Note that if you don’t have a line terminator at the end of the
Main-Classline in the manifest, that will cause an error, but it’s somewhat better specified: