首先我在D盘创建Doc文件夹,这样设置的CLASSPATH变量(.;D:\JAVA\j2sdk1.4.2_08\lib\tools.jar;D:\Doc),然后在Doc文件夹里创建P.java,即
package com.bruceeckel.tools;
public class P {
public static void rintln(String s) {
System.out.println(s);
}
}
编译后,P.class位于刚创建的D:\Doc\com\bruceeckel\tools中,然后在Doc文件夹里创建Test.java,即
import com.bruceeckel.tools.*; //改为import com.bruceeckel.tools.P就好了
public class Test {
public static void main(String[] args) {
p.rintln("aa");
}
}
编译时提示错误,
bad class file: D:\Doc\P.java
file does not contain class P
Please remove or make sure it appears in the correct subdirectory of the classpath.
P.rintln("aa");
^
1 error
package com.bruceeckel.tools;
public class P {
public static void rintln(String s) {
System.out.println(s);
}
}
编译后,P.class位于刚创建的D:\Doc\com\bruceeckel\tools中,然后在Doc文件夹里创建Test.java,即
import com.bruceeckel.tools.*; //改为import com.bruceeckel.tools.P就好了
public class Test {
public static void main(String[] args) {
p.rintln("aa");
}
}
编译时提示错误,
bad class file: D:\Doc\P.java
file does not contain class P
Please remove or make sure it appears in the correct subdirectory of the classpath.
P.rintln("aa");
^
1 error
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货