问题
I need to develop a sample Application and deploy it in Linux and test it .
The problem is that I am getting
Exception in thread "main" java.lang.ClassFormatError: com.tata.topSamples.QuoteData (unrecognized class file version)
at java.lang.VMClassLoader.defineClass(libgcj.so.7rh)
at java.lang.ClassLoader.defineClass(libgcj.so.7rh)
at java.security.SecureClassLoader.defineClass(libgcj.so.7rh)
at java.net.URLClassLoader.findClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at gnu.java.lang.MainThread.run(libgcj.so.7rh)
By googling I found out that , You compiled the jar with a newer version of Java than the one on your Linux machine
In my windows Environment I have 1.6 version and in Linux Environment the java version is of 1.4.2.
How can we resolve this error?
回答1:
Please tell me how can we resolve this error ??
Either compile with -target 1.4
and -source 1.4
flags, or update to a more recent version of Java on your Linux box. (Note that using those flags allows you to keep the more recent version of the JDK on your Windows box.)
So:
javac -target 1.4 -source 1.4 Foo.java Bar.java
Do you have to use GCJ rather than (say) OpenJDK?
回答2:
Upgrade the version in your Linux environment, or build it with 1.4.2 on Windows.
来源:https://stackoverflow.com/questions/9634768/java-lang-classformaterror