当前位置: 技术问答>linux和unix
LINUX 安装JDK的问题
来源: 互联网 发布时间:2016-07-15
本文导语: 以前在虚拟机上装过 今天在真实机器上装出现问题了。恳请高手帮忙 不胜感激 版本:red hat Enterprise 4 jdk:1.6.0_13 设置的环境变量: # set java environment JAVA_HOME=/usr/java/jdk1.6.0_13 PATH=$PATH:$JAVA_HOME/bin ...
以前在虚拟机上装过 今天在真实机器上装出现问题了。恳请高手帮忙 不胜感激
版本:red hat Enterprise 4 jdk:1.6.0_13
设置的环境变量:
# set java environment
JAVA_HOME=/usr/java/jdk1.6.0_13
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME PATH CLASSPATH
[yurui@localhost tmp]$ java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
HelloWorld.java代码:
public class HelloWorld{
public static void main(String[] args){
System.out.println("hello!");
}
}
运行一个试验程序:出现一大堆错误代码:
[yurui@localhost tmp]$ javac HelloWorld.java
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.Pro
tectionDomain) (/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)
版本:red hat Enterprise 4 jdk:1.6.0_13
设置的环境变量:
# set java environment
JAVA_HOME=/usr/java/jdk1.6.0_13
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME PATH CLASSPATH
[yurui@localhost tmp]$ java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
HelloWorld.java代码:
public class HelloWorld{
public static void main(String[] args){
System.out.println("hello!");
}
}
运行一个试验程序:出现一大堆错误代码:
[yurui@localhost tmp]$ javac HelloWorld.java
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.Pro
tectionDomain) (/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)
|
改下PATH吧
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATH