I have a problem creating and executing a JAR file. I have already made a JAR file, but when I execute it with java -jar, I am getting an error Error: could not find and load main class ... I make a JAR file with jar cvfm, but I execute it from C:\Program Files\Java\jdk1.70\
What’s wrong with this?
To create an executable jar file you have to specify the entry point to the jar.Like this:
jar -cvfe “jar file name” “Main Class Name(Ex com.test.MainTest)” “Files to be included in the jar”
If you already have a jar file, you can update the manifest file by creating an “additions” file and running the command to include the main class :
Main-Class: Classname
and run command:
jar ufm “jarfilename” “additions manifest”