javac encounter 'java.lang.ClassFormatError' error

Copied a Java source file to Oracle Apps Server, and Tried to use javac command to compile it. But javac raise below error:

-bash-3.00$ javac

Exception in thread "main" java.lang.ClassFormatError: com.sun.tools.javac.main.Main (erroneous method access flags)
   at _Jv_ClassReader.throw_class_format_error(byte) (/usr/lib/libgcj.so.5.0.0)
   at _Jv_ClassReader.handleMethod(int, int, int, int) (/usr/lib/libgcj.so.5.0.0)
   at _Jv_ClassReader.read_methods() (/usr/lib/libgcj.so.5.0.0)
   at _Jv_ClassReader.parse() (/usr/lib/libgcj.so.5.0.0)
   at _Jv_DefineClass(java.lang.Class, byte[], int, int) (/usr/lib/libgcj.so.5.0.0)
   at java.lang.VMClassLoader.defineClass(java.lang.ClassLoader, java.lang.String, byte[], int, int, java.security.ProtectionDomain) (/usr/lib/libgcj.so.5.0.0)
   at java.lang.ClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.ProtectionDomain) (/usr/lib/libgcj.so.5.0.0)
   at java.security.SecureClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.CodeSource) (/usr/lib/libgcj.so.5.0.0)
   at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
   at gnu.gcj.runtime.VMClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
   at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.5.0.0)
   at _Jv_FindClass(_Jv_Utf8Const, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
   at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
   at _Jv_BytecodeVerifier.verify_instructions_0() (/usr/lib/libgcj.so.5.0.0)
   at _Jv_VerifyMethod(_Jv_InterpMethod) (/usr/lib/libgcj.so.5.0.0)
   at _Jv_PrepareClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
   at _Jv_WaitForState(java.lang.Class, int) (/usr/lib/libgcj.so.5.0.0)
   at java.lang.VMClassLoader.linkClass0(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
   at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
   at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.5.0.0)
   at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
   at java.lang.Class.forName(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
   at gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.5.0.0)
   at _Jv_ThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.5.0.0)
   at _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/libgcj.so.5.0.0)
   at __libc_start_main (/lib/tls/libc-2.3.4.so)

-bash-3.00$


Checking Points

-bash-3.00$ which javac
/usr/bin/javac


-bash-3.00$ which java
~/apps/tech_st/10.1.3/appsutil/jdk/jre/bin/java


-bash-3.00$ java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Server VM (build 14.3-b01, mixed mode)


Solution

It seems default javac command(/usr/bin/javac) doesn't work fine.

My solution is,Under directory /local/java/, there are many different version jdk or jre, choose a proper one to compile to your java file,
My Case:

/local/java/jdk1.6.0_17/bin/javac *.java



你可能感兴趣的:(javac encounter 'java.lang.ClassFormatError' error)