关于文件路径一问
import com.bruceeckel.simpletest.*;
class Candy {
static {
System.out.println( "Loading Candy ");
}
}
class Gum {
static {
System.out.println( "Loading Gum ");
}
}
class Cookie {
static {
System.out.println( "Loading Cookie ");
}
}
public class SweetShop {
private static Test monitor = new Test();
public static void main(String[] args) {
System.out.println( "inside main ");
new Candy();
System.out.println( "After creating Candy ");
try {
Class.forName( "Gum ");
} catch(
ClassNotFoundException e) {
System.out.println( "Couldn 't find Gum ");
}
System.out.println( "After Class.forName(\ "Gum\ ") ");
new Cookie();
System.out.println( "After creating Cookie ");
monitor.expect(new String[] {
"inside main ",
"Loading Candy ",
"After creating Candy ",
"Loading Gum ",
"After Class.forName(\ "Gum\ ") ",
"Loading Cookie ",
"After creating Cookie "
});
}
} ///:~
就是那个Class.forname里编译器说找不到Gum类,请问怎么写全路径
我的SweetShop.java存在E:\jdk\STRING\chen\hao3下.大家指点一下 谢谢
帮我写出forname里的完整路径
------解决方案--------------------还有包的名字呢
------解决方案--------------------Class.forName( "E:\\jdk\\STRING\\chen\\hao3Gum ");
给分
------解决方案--------------------com.bruceeckel.simpletest
还要SweetShop$吗?
------解决方案--------------------learnning
------解决方案--------------------chen.hao3.Gum不行的话就chen.hao3.SweetShop$Gum
实在不行你在去掉数字试试
------解决方案--------------------你写文件路径它能对吗?写包名.类名
------解决方案--------------------你classpath里面加E:\jdk\STRING了么?
forname 里面要写带包前缀的类名
------解决方案--------------------其实就是个路径问题~~~