ubuntu下的JAVA问题---关于java版本冲突什么的
我昨晚安装了sunjava,然后就不可以运行java程序了java Hello
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
Caused by: java.lang.ClassNotFoundException: Hello
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
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)
Could not find the main class: Hello. Program will exit.
搜索了后,说是jre版本冲突什么的,ubuntu下我先安装了个
jre-6u24-linux-i586.bin
后来又安装了
jdk-6u24-linux-i586.bin
这两个应该是可以的哈,难道是和ubuntu自带的openJDK冲突么?
后来我设置了默认JDK为sunJDK啊,还是不行。
javac Hello.java 可以生成.class文件,但是java Hello,就不行了··
求指教
谢谢各位了
java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)
javac -version
javac 1.6.0_24
----------
这有什么问题吗?
这是/etc/environment下的配置文件
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
export JAVA_HOME=/home/liuyu/Java/jdk1.6.0_23
export JRE_Home=/home/liuyu/Java/jdk1.6.0_23/jre
export CLASSPATH=$CLASSPATHhttp://www.tizennet.com/static/image/smiley/default/shy.gifJAVA_HOME/libhttp://www.tizennet.com/static/image/smiley/default/shy.gifJAVA_HOME/jre
然后我再
sudo gedit /etc/profile
里面也添加了
export JAVA_HOME=/home/liuyu/Java/jdk1.6.0_23
export JRE_HOME=/home/liuyu/Java/jdk1.6.0_23/jre
export CLASSPATH=$CLASSPATHhttp://www.tizennet.com/static/image/smiley/default/shy.gifJAVA_HOME/libhttp://www.tizennet.com/static/image/smiley/default/shy.gifJAVA_HOME/jre/lib
export PATH=$JAVA_HOME/binhttp://www.tizennet.com/static/image/smiley/default/shy.gifJAVA_HOME/jre/binhttp://www.tizennet.com/static/image/smiley/default/shy.gifPATHhttp://www.tizennet.com/static/image/smiley/default/shy.gifHOME/bin
------------
以上就是我的配置了
有大大看出问题在哪么--
-------------------------------------------------------------------------------
回答:
PATH="/home/liuyu/Java/dk1.6.0_23 /bin"
CLASSPATH="/home/liuyu/Java/dk1.6.0_23/lib"
这样试试.. 你那个指向jre干嘛? 还装载home里面 咋不放到usr里面
--------------------------------------------------------------------------------
回答2:
path:
%java_home%/bin
classpath:
.;%java_home%/lib/dt.jar;%java_home%/lib/htmlconverter.jar;%java_home%/lib/jconsole.jar;%java_home%/lib/tools.jar;
java_home
/home/liuyu/Java/dk1.6.0_23
其它的不用管,这三个配对了,我包你不会再有问题
佩服佩服!
页:
[1]