java.lang.ClassFormatError

旧街凉风 提交于 2020-01-15 03:44:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!