当前位置: 技术问答>java相关
Linux 下 HelloWorld 问题
来源: 互联网 发布时间:2015-05-30
本文导语: 源文件如下: class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } 编译:javac HelloWorld.java 生成HelloWorld.class 运行: java HelloWorld 时出错如下所示 Exception in thread "main" java.lang.NoCl...
源文件如下:
class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
编译:javac HelloWorld.java 生成HelloWorld.class
运行: java HelloWorld 时出错如下所示
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
我已经在/etc/profile将classpath设为CLASSPATH=".;/www/jdk1.2.2/lib/tools.jar"
export CLASSPATH
问题出在何处?
class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
编译:javac HelloWorld.java 生成HelloWorld.class
运行: java HelloWorld 时出错如下所示
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
我已经在/etc/profile将classpath设为CLASSPATH=".;/www/jdk1.2.2/lib/tools.jar"
export CLASSPATH
问题出在何处?
|
在/etc/profile将classpath设为CLASSPATH=.;/jdk1.2.2/lib/
export CLASSPATH
export CLASSPATH
|
将JDK装到/usr/local目录下
编辑ect/profile 在文件末尾加入:PATH="$PATH:/usr/local/jdk1.2.2/bin:/usr/local/jdk1.2.2/jre/bin"
JAVA_HOME=/usr/local/jdk1.2.2
export JAVA_HOME
JRE_HOME=/usr/local/jdk1.2.2/jre
export JRE_HOME
CLASSPATH=/usr/local/jdk1.2.2/lib:/usr/local/jdk1.2.2/jre/lib
export CLASSPATH
编辑ect/profile 在文件末尾加入:PATH="$PATH:/usr/local/jdk1.2.2/bin:/usr/local/jdk1.2.2/jre/bin"
JAVA_HOME=/usr/local/jdk1.2.2
export JAVA_HOME
JRE_HOME=/usr/local/jdk1.2.2/jre
export JRE_HOME
CLASSPATH=/usr/local/jdk1.2.2/lib:/usr/local/jdk1.2.2/jre/lib
export CLASSPATH