I have been experimenting with making my own JAR files. Some of which work and some don't. After hours of altering the application I haven't been able work out why they sometimes work and sometimes don't.
When the JAR file won't run I get an Exception in thread "Main" java.lang.NoClassDefFoundError ,but at other times I get an Exception in thread "main" java.lang.ClassFormatError: MyClass (Bad magic number).
I create and run the jar file using the following steps:
You seem to be doing everything right. I tried what you are trying and it works fine for me. I get the feeling that you may have some kind of version problems. Are you running a new version of javac but an older version of jar?