我的CODE是 public class ellsworth{ public static void main(string[] arguments){ string line1="the advancement of the arts,from year\n"; string line2="to year,taxes our credulity, and seems\n"; string line3="to presage the arrival of that period\n"; string line4="when human improvement must end."; string quote=line1+line2+line3+line4; string speaker="henry ellsworth"; string title="u.s. commissioner of patents"; string from="1843 annual report of the paten office"; system.out.printIn('\u0022'+quote+'\u0022'); system.out.printIn("\t"+speaker); system.out.printIn("\t"+title); system.out.printIn("\t"+from); } }
public class ellsworth{ public static void main(String[] arguments){ String line1="the advancement of the arts,from year\n"; String line2="to year,taxes our credulity, and seems\n"; String line3="to presage the arrival of that period\n"; String line4="when human improvement must end."; String quote=line1+line2+line3+line4; String speaker="henry ellsworth"; String title="u.s. commissioner of patents"; String from="1843 annual report of the paten office"; System.out.println('\u0022'+quote+'\u0022'); System.out.println("\t"+speaker); System.out.println("\t"+title); System.out.println("\t"+from); } } 把文件存为ellsworth.java,然后运行:javac ellsworth.java,再运行java ellsworth
java ellsworth //运行程序
出现Exception in thread "main" java.lang.NoClassDefFoundError: ellsworth为什么?
(2) 书上写得没有错,你根本就没有理解对,所以打错了;
(3) 书上写得没有错,你理解得也没有错,但是手误打错了;
...原因可能有好多..@@不过看你的问题,绝对属于没有理解对的类型,至少两个明显的错误:
(1) 去运行ellsworth.java的错误
(2) 用j2re去写java的错误PS: j2re = Java 2 Runtime Environment <-- 是运行时环境,不是给你写程序用的
还不可以就把这个环境变量删除。
classpath 设置的问题呵呵把你编译成.class文件所在目录加到classpath里面试试
要下一个j2se的开发包去java.sun.com上就能得到,免费。还有,
javadoc也是比较方便的辅助工具,想字典一样,也推荐你一并下载。good luck
public class ellsworth{
public static void main(string[] arguments){
string line1="the advancement of the arts,from year\n";
string line2="to year,taxes our credulity, and seems\n";
string line3="to presage the arrival of that period\n";
string line4="when human improvement must end.";
string quote=line1+line2+line3+line4;
string speaker="henry ellsworth";
string title="u.s. commissioner of patents";
string from="1843 annual report of the paten office";
system.out.printIn('\u0022'+quote+'\u0022');
system.out.printIn("\t"+speaker);
system.out.printIn("\t"+title);
system.out.printIn("\t"+from);
}
}
public static void main(String[] arguments){
String line1="the advancement of the arts,from year\n";
String line2="to year,taxes our credulity, and seems\n";
String line3="to presage the arrival of that period\n";
String line4="when human improvement must end.";
String quote=line1+line2+line3+line4;
String speaker="henry ellsworth";
String title="u.s. commissioner of patents";
String from="1843 annual report of the paten office";
System.out.println('\u0022'+quote+'\u0022');
System.out.println("\t"+speaker);
System.out.println("\t"+title);
System.out.println("\t"+from);
}
}
把文件存为ellsworth.java,然后运行:javac ellsworth.java,再运行java ellsworth
装的就是他
1.PATH的设置:找到名称为path的变量,在内容的后面加上
“;d:\j2sdk1.4.2_4\bin”
2.CLASSPATH的设置:新建->
变量名:“CLASSPATH”
变量值:“.;d:\j2sdk1.4.2_4\lib\tools.jar;d:\j2sdk1.4.2_4\lib\dt.jar”
3.TOMCAT_HOME的设置:新建->
变量名:“TOMCAT_HOME”
变量值:“d:\Tomcat 5.0”
4.JAVA_HOME的设置:新建->
变量名:“JAVA_HOME”
变量值:“d:\j2sdk1.4.2_4\”
注意改称你自己的安装目录,
刚开始的时候可以不加后面两个
为了你们如此热心我也应该学好JAVA
然后java ellsworth
如:
package org.xp.java; public class Hello {
...
}//这个时候HelloWorld.java放在文件夹"..\org\xp\java\"下面。这篇文章应该对你有帮助:
http://www.javaworld.com.tw/jute/post/view?bid=29&id=13627&sty=3&age=0&tpg=1&ppg=1
而且Sytem.out.println()中的“ln”你是不是也写成了“In”?
看来楼主没有真正按照书上的打吧!:)
good luck!
Consult the following stack trace for details.
java.lang.OutOfMemoryError
书上的程序错误,请改正后进行运行,顺便注意大小写:)!
classpath问题
应该是你的JDK没有安装或者安装有错.请重新弄一下吧~~~
运行: java -cp . ellsworth