Error during conversion of .class file to jar file
I am unable to understand the reason behind the error.I want to convert .class file to jar file,
on dos i write :
java cf myjar.jar *.class
but here is what i get in return:
Error: Could not find main class cf Exception in thread "mai开发者_JS百科n" java.lang.NoClassDefFoundError: cf
---and goes on,,,,
Why i am getting this error and what is it?
You're running the wrong command - java
instead of jar
. That's why it's treating cf
as a class name.
You want:
jar cf myjar.jar *.class
First you need to use the jar command, java command is to running while the jar command will create the .jar file.
You also need to include a manifest file, which will determine the main class of your application. See Working with Manifest Files. Without a manifest file you will need to specify the main class when running the app, like "java -cp JARFILE.jar package.MyMain"
精彩评论