A little help from you all... I was trying to convert a simple java program into jar but nothing seems to have happened. I have 2 files: Tester.java , Tester.Class. Then I used this command line:
jar -cvf Tester.jar Tester.class
The .jar file was created but nothing seems to work. What did I miss?
To run the program in the jar file you created you would need to execute
java -cp Tester.jar your.package.Main
A more convenient way to execute the jar is to be able to do
java -jar Tester.jar
That, however, requires that you specify the main-class in a manifest file, that should be included in the jar-file:
Put
Manifest-Version: 1.2
Main-Class: your.package.Main
in manifest.txt
And to create the jar:
jar cvfm Tester.jar manifest.txt Tester.class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With