Jar file execution error
I wrote a program that runs fine, however packaging the file into a jar file and trying to execute that fails.
The project consists of three files :
CinReader.java --> CinReader.class
PageSource.java --> PageSource.class
LocalBot.java --> LocalBot.class (main class)
The contents of manifest.txt are : Main-Class: LocalBot.class
I created the jar file with the command :
C:\Users\ioil\Desktop\CSCI20\localBot>jar cvfm LocalBot.jar manifest.txt *.class
added manifest
adding: CinReader.class(in = 5908) (out= 3027)(deflated 48%)
adding: LocalBot.class(in = 362) (out= 272)(deflated 24%)
adding: PageSource.class(in = 5293) (out= 2560)(deflated 51%)
C:\Users\ioil\Desktop\CSCI20\localBot>
Now when I enter the command : "java -jar LocalBot.jar"
or "LocalBot.jar"
the Java Virtual Machine Launcher returns the error message : "Could not find the main开发者_开发技巧 class: LocalBot. Program will exit"
Am I doing anything obviously wrong . . .
Take a look at Understanding the Manifest
When you create a JAR file, it automatically receives a default manifest file. There can be only one manifest file in an archive, and it always has the pathname
META-INF/MANIFEST.MF
精彩评论