- Your Java File (source code)
MyGame.java
- Compile the Java File to a *.class file. This is Java bytecode that can be executed on the Java Virtual Machine (JVM). JVM is installed automatically when we install Java and it will be invoked automatically when we run a java program.
Note : In Eclipse, "run" perform both compilation and execution.javac MyGame.java
- This will create a
MyGame.class
file
- This will create a
- Execution of the Java File
java MyGame
- Creation of an executable
*.jar
file. A jar file is simply a file containing a collection of java files.
First, create a manifest file : touch manifest.mfIn the manifest file, point Main-Class to our java file that has main entry point i.e. main() method. For example,
Make sure the compiled output class files (myGame.class) and the manifest file are in the same folder.Manifest-Version: 1.0 Main-Class: MyGame
Create the .jar file by the following :jar cfm MyGame.jar manifest.mf *.class
- To run the Jar File
java -jar MyGame.jar