Search code examples
javajarnoclassdeffounderrorjava-6

java returning "NoClassDefFound" error; thinks -jar option is a runnable class


java -jar <Name of executable jar>

Results in my 1.6 jvm returning a NoClassDefFound error for 'jar'. Why isn't it recognising -jar as an option and not a class to run?

jar structure: The manifest points Main-Class at com.mycompany.EntryPoint.class, which is inside the jar. It also specifies Ant-Version too and I haven't set ANT_HOME env variable (running on windows).

exact runtime error:

Exception in thread "main" java.lang.NoClassDefFoundError: ûjar
caused by java.lang.ClassNotFoundException: ûjar
...

manifest:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.1
Created-By: [redacted]
Main-Class: com/mycompany/EntryPoint

Edit: No idea why but I tried it once more and this time it executed the jar as expected.


Solution

  • Probably the '-' character you're using for the '-jar' flag is not the standard ASCII '-' sign, but some kind of UTF-8 special character.

    Remove it and replace it with the normal ASCII '-' sign.