what's wrong with jdk?(100分)

  • 主题发起人 主题发起人 eversun
  • 开始时间 开始时间
E

eversun

Unregistered / Unconfirmed
GUEST, unregistred user!
I created HelloWorldApp.java as follows:
class HelloWorldApp {
public static void main(String[] args) {
// Display "Hello World!"
System.out.println("Hello World!");
}
}
step1: javac HelloWorldApp.java (no error)
step2: java HelloWorldApp
sometimes it's ok, but most time there's error as follows:
Exception in thread "main" java.lang.NoClassDefFoundError:HelloWorldApp
 
很明显, classpath 没设, 可在本论坛 java 版查一下,
这是 java 初学者的一个最大的问题.
 
should I set classpath in JDK1.3 envirement? I found there's JDK1.3
envirement in system registry.
 
不是在registry里。
win2000&NT:我的电脑->属性,自己找一下。
98:运行sysedit,在Autoexec.bat里设置。
如果你的JDK的目录为C:/JDK;HelloWorldApp.java及其class文件
的目录为C:/myjava;进行以下设置:
set classpath=c:/myjava
set path=c:/jdk/bin

 
加一个 classpath=c:/java/jre/lib/rt.jar试试
 
好像是路径设的不对
 

>如果你的JDK的目录为C:/JDK;HelloWorldApp.java
>及其class文件的目录为C:/myjava;进行以下设置:
>set classpath=c:/myjavaset path=c:/jdk/bin
我试了一下,eguy的方法可以.不过,还有别的方法吗?
然道换一个java文件路径,还得重设classpath?
 
It seems we needn't set any in JDK1.3
 

To eversun:
我就是用JDK1.3,若不设classpath,一样有问题(编译application不通过)
 
I didn't set classpath, but it's running ok!
 
Set the classpath evironment variable to include the root for classes that
you provided. Or you can pass it directly to the javaVM by specifying
options in the command line as shown below,

java -cp <my_root_to_class_file> <fullpath_of_my_class_file>
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
2K
import
I
I
回复
0
查看
3K
import
I
I
回复
0
查看
1K
import
I
I
回复
0
查看
3K
import
I
I
回复
0
查看
3K
import
I
后退
顶部