I typed in "java -jar ShowTime.jar", and got this error message:
Exception in thread "main" java.lang.ClassFormatError: Incompatible magic value 1347093252 in class file ShowTime
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
How should I fix this? P.S. I have a mac.
A Java class should start with the magic (hex) value 0xCAFEBABE
(neat huh). Your value 1347093252
is 0x504B0304
in hex, which happens to be the magic value for a ZIP file (first 2 bytes in ASCII are PK for Phil Katz, creator of the ZIP format). A jar is also a zipfile btw, so probably your jar is pretty much corrupt. Try rebuilding the entire project.
That usually means that you compiled the jar for a newer version of java than you ran it with. Check to see if you are using the same version of java to compile and run. If that doesn't fix the problem, please provide more info such as the compiler command and the output of java -version
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With