Ubuntu – How to run a .JAR file via the terminal

command lineeclipsejava

Mispelled classname in manifest.txt file caused this error

enter image description hereenter image description hereIm trying to run a java file outside of my IDE by exporting the .jar file to my documents folder and trying to display the text 'hello world'in the file on the terminal line. I attempted to create a Manifest.txt file with this in it,

Main-Class: lightning.java.hello.MyFirstClass

I then used this script to create a file MyJar.jar and got this back,

lightning@rigel5:~$ jar cfm MyJar.jar Manifest.txt lightning.java.hello/*.class
java.io.FileNotFoundException: Manifest.txt (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:97)
at sun.tools.jar.Main.run(Main.java:171)
at sun.tools.jar.Main.main(Main.java:1177)

Best Answer

You can run java package using this command on your terminal:

java -jar MyFirstClass.jar

If you don't have Java Runtime Edition (JRE) you'll need to install default-jre package.

Related Question