当前位置: 技术问答>java相关
菜鸟问题:HelloWorld 也会出
来源: 互联网 发布时间:2015-04-07
本文导语: 我刚接触Java,下载了JDK1.3,安装完后写了第一个程序,可是竟然出错,请侠客们看看 错在哪里: public class HelloWorld { private String helloMsg = "Hello World !"; public static void main(String[] args) { HelloWorld hw = new Hel...
我刚接触Java,下载了JDK1.3,安装完后写了第一个程序,可是竟然出错,请侠客们看看
错在哪里:
public class HelloWorld
{
private String helloMsg = "Hello World !";
public static void main(String[] args)
{
HelloWorld hw = new HelloWorld();
}
public HelloWorld()
{
System.out.println(helloMsg);
}
}
c:java HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
错在哪里:
public class HelloWorld
{
private String helloMsg = "Hello World !";
public static void main(String[] args)
{
HelloWorld hw = new HelloWorld();
}
public HelloWorld()
{
System.out.println(helloMsg);
}
}
c:java HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
|
set classpath=.;c:jdk1.3.1-02libtools.jar
|
先执行javac
|
javac HelloWorld.java
java HelloWorld
java HelloWorld