need help...success in compile with .jar, but fail in running
I have a jar file that contains a package. I enter this command and it compiles:
javac -cp "C:\Program Files\Java\jdk1.5.0_05\bin\myPac.jar" app.java
but when I try to run the program by typing this command:
java -cp "C:\Program Files\Java\jdk1.5.0_05\bin\myPac.jar" app
It doesn't run and i get this exception error:
Exception in thread "main" java.lang.NoClassDefFoundError: app
Any ideas?
Re: need help...success in compile with .jar, but fail in running
Does the jar file contain a manifest file?
Not sure, but I believe you might have to specify the class file to run in a manifest file.
Re: need help...success in compile with .jar, but fail in running
Does the java command need a -jar switch to run a jar file?
Re: need help...success in compile with .jar, but fail in running
Yep, that's another thing you are missing.
Your running should look like this:
java -jar jar-file
But you also need the Main-Class header in the manifest file to indicate the entry point to the app.