Topic: 我刚装好JDK1.4.2,怎么程序不能运行啊?!!! |
Print this page |
1.我刚装好JDK1.4.2,怎么程序不能运行啊?!!! | Copy to clipboard |
Posted by: spark07 Posted on: 2006-07-05 14:12 我刚装好JDK1.4.2,写了个小程序想测试一下,程序如下: public class Hello{ public static void main(String[] args){ System.out.println("Hello,world!"); } } 我存贮为文件:Hello.java,然后我就编译了,编译过程正常,生成了一个Hello.class文件,然后我就用命令java Hello运行这个Hello.class文件,可竟然不能运行,JDK提示如下:Exception in thread "main" java.long.NoClassDefFoundError:Hello 我想了半天也不知道是哪里出了毛病,我是个JAVA新手,还请各位大哥哥大姐姐多多指教小弟弟!!! 小弟弟先谢谢大哥哥大姐姐了!!! |
2.Re:我刚装好JDK1.4.2,怎么程序不能运行啊?!!! [Re: spark07] | Copy to clipboard |
Posted by: spark07 Posted on: 2006-07-05 17:30 咋就没有一个人帮俺恁??? 才三個小時,可否給點耐心?沒耐心的話,請便。 |
3.Re:我刚装好JDK1.4.2,怎么程序不能运行啊?!!! [Re: spark07] | Copy to clipboard |
Posted by: Jcat Posted on: 2006-07-05 17:40 Confirm your classpath is like ".;%JAVA_HOME%/lib" Note: there is a dot (.), with which means classes in current dir are also included in classpath. |
4.Re:我刚装好JDK1.4.2,怎么程序不能运行啊?!!! [Re: spark07] | Copy to clipboard |
Posted by: spark07 Posted on: 2006-07-05 18:27 yes ,i ensured that i have added "."before";%JAVA_HOME%/lib",but the problem go on! how can i resolve it? |
5.Re:我刚装好JDK1.4.2,怎么程序不能运行啊?!!! [Re: spark07] | Copy to clipboard |
Posted by: why Posted on: 2006-07-05 19:28 java -cp . Hello [corrected as YuLimin pointed out] search for NoClassDefFoundError read [加贴须知] |
6.Re:我刚装好JDK1.4.2,怎么程序不能运行啊?!!! [Re: why] | Copy to clipboard |
Posted by: YuLimin Posted on: 2006-07-05 21:47 why wrote: java -cp . Hello cp后面少了一个空格:) |
7.Re:我刚装好JDK1.4.2,怎么程序不能运行啊?!!! [Re: spark07] | Copy to clipboard |
Posted by: lbfhappy Posted on: 2006-07-06 11:51 有道理 |
8.Re:我刚装好JDK1.4.2,怎么程序不能运行啊?!!! [Re: spark07] | Copy to clipboard |
Posted by: spark07 Posted on: 2006-07-06 12:18 now it's normal when i use the command:java -cp . Hello but i do want it can run normally with the command:java Hello, what should i do? |
9.Re:我刚装好JDK1.4.2,怎么程序不能运行啊?!!! [Re: spark07] | Copy to clipboard |
Posted by: YuLimin Posted on: 2006-07-07 21:03 在系统变量里设置:CLASSPATH=.; Windows 2K 按如下顺序做: 1、按下:Win键 + Pause Break 2、选取“高级”; 3、点击“环境变量”按钮; 4、点击系统变量中的“新建”按钮; 5、变量名输入CLASSPATH 6、变量值输入.; 一路确定回去:) 重新进入DOS java hELLO 之:) (*_*) |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |