I\'m trying to execute a Java program from the command line in Windows. Here is my code:
import java.io.File;
import java.io.FileInputStream;
import java.io.
To complete the answer :
The Java File
TheJavaFile.java
Compile the Java File to a *.class file
javac TheJavaFile.java
TheJavaFile.class
fileExecution of the Java File
java TheJavaFile
Creation of an executable *.jar
file
You've got two options here -
With an external manifest file :
Create the manifest file say - MANIFEST.mf
The MANIFEST file is nothing but an explicit entry of the Main Class
jar -cvfm TheJavaFile.jar MANIFEST.mf TheJavaFile.class
Executable by Entry Point:
jar -cvfe TheJavaFile.jar TheJavaFile.class
To run the Jar File
java -jar TheJavaFile.jar