怪事!!!!!!!!(100分)

  • 主题发起人 主题发起人 sinsou
  • 开始时间 开始时间
S

sinsou

Unregistered / Unconfirmed
GUEST, unregistred user!
怪事!!!!!!!!

c:盘安装的是win98,也安装了jdk1.3 目录为 c:/jdk1.3
d:盘安装的是winnt,也安装了jdk1.3 目录为 d:/jdk1.3
一个java程序,在win98的msdos下能正确运行,在nt下却出现错误,
nt 下的classpath 设置如下:d:/jdk1.3/lib/tools.jar;d;/jdk1.3/dt.jar
Exception in thread "main" java.lang.NoClassDefFoundError;
 
把c盘的jdk卸载掉试试。
 
你可以试试看将classpath设置改为d:/jdk1.3/lib/*.*
 

建议只装一个jdk.
 
可能是你的路径指到了dos的jdk而classpath指向了nt的jar
 
NT的环境变量classpath的设置应在其中包含".",即当前路径。否则找不到当前路径下的类。
(98同)
 
sinsou:
如长袜子皮皮所说的try it!或直接将你的程序所在目录加入classpath,一定OK。
成功后,请结束问题
 
D:/jdk>dir
Volume in drive D has no label
Volume Serial Number is 1CDC-2363
Directory of D:/jdk
. <DIR> 09-21-00 17:35 .
.. <DIR> 09-21-00 17:35 ..
UNINST ISU 192,510 09-21-00 17:35 Uninst.isu
BIN <DIR> 09-21-00 17:35 bin
README 5,910 06-29-99 6:20 README
LICENSE 8,617 06-29-99 6:20 LICENSE
COPYRI~1 946 06-29-99 6:20 COPYRIGHT
README~1 HTM 21,014 06-29-99 6:20 readme.html
JRE <DIR> 09-21-00 17:35 jre
LIB <DIR> 09-21-00 17:35 lib
INCLUDE <DIR> 09-21-00 17:35 include
INCLUD~1 <DIR> 09-21-00 17:35 include-old
DEMO <DIR> 09-21-00 17:35 demo
SRC JAR 17,288,462 06-29-99 6:20 src.jar
6 file(s) 17,517,459 bytes
8 dir(s)
D:/jdk>set
TMP=C:/WINDOWS/TEMP
TEMP=C:/WINDOWS/TEMP
PROMPT=$p$g
winbootdir=C:/WINDOWS
COMSPEC=C:/COMMAND.COM
PATH=C:/WINDOWS;C:/WINDOWS/COMMAND;D:/JDK/BIN
JAVA_HOME=d:/jdk
CLASSPATH=d:/jdk/lib/tools.jar;d:/jdk/lib/;d:/jdk/jre/lib
windir=C:/WINDOWS
CMDLINE=java .
638.76 MB free
D:/jdk>type Welcome.java
public class Welcome
{ public static void main(String[] args)
{ String[] greeting = new String[3];
greeting[0] = "Welcome to Core Java";
greeting[1] = "by Cay Horstmann";
greeting[2] = "and Gary Cornell";
int i;
for (i = 0;
i < greeting.length;
i++)
System.out.println(greeting);
}
}
D:/jdk/corejava/v1ch2/Welcome>java Welcome.class
Exception in thread "main" java.lang.NoClassDefFoundError: Welcome/class
D:/jdk/corejava/v1ch2/Welcome>java .
Exception in thread "main" java.lang.NoClassDefFoundError: /
????????????????????????????????????????????????????????????????????????????
Help ME ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
请把 . 加入到classpath中.
比如 set classpahth=.;
.......
 
在Welcome.class所在的目录
打 >java -classpath . Welcome即可
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
877
DelphiTeacher的专栏
D
D
回复
0
查看
845
DelphiTeacher的专栏
D
D
回复
0
查看
795
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部