我的程序不是jsp用,是application,我现在在那3个目录下都建了com\util 并且类文件拷过去了,提示错误是 error: File .\MyList.class does not contain type MyList as expected, but type com.util.MyList. Please remove the file, or make sure it appears in the correct subdirectory of the class path.Mylist.class就是我要引用的类。
还是不好用,错误还是一样的 error: File .\MyList.class does not contain type MyList as expected, but type com.util.MyList. Please remove the file, or make sure it appears in the correct subdirectory of the class path.
我用的是jdk1.2.2,难道用它不行吗?源程序: //: MyList.java // Creating a package package com.util;public class MyList { public MyList() { System.out.println( "com.bruceeckel.util.List"); } } ///:~//: MyListTest.java // Uses the library //package c05; import com.util.*;public class MyListTest { public static void main(String[] args) { MyList l = new myList(); } } ///:~
然后在f:\java\com下建一个util,
然后在f:\java\com\util下建Java文件,编译之。
并不输出的.class文件放在里面。如果直接用Javac在命令行编译的话,就需要自己手动建立目录com\util。将编译好的.class文件放在如下目录里即可:webapps\root\WEB-INF\classes\com\utial
并把输出的.class文件放在里面。如果直接用Javac在命令行编译的话,就需要自己手动建立目录com\util。将编译好的.class文件放在例如下面的目录即可:webapps\root\WEB-INF\classes\com\utial
并且类文件拷过去了,提示错误是
error: File .\MyList.class does not contain type MyList as expected, but type com.util.MyList. Please remove the file, or make sure it appears in the correct subdirectory of the class path.Mylist.class就是我要引用的类。
error: File .\MyList.class does not contain type MyList as
expected, but type com.util.MyList. Please remove the file, or make
sure it appears in the correct subdirectory of the class path.
//: MyList.java
// Creating a package
package com.util;public class MyList {
public MyList() {
System.out.println(
"com.bruceeckel.util.List");
}
} ///:~//: MyListTest.java
// Uses the library
//package c05;
import com.util.*;public class MyListTest {
public static void main(String[] args) {
MyList l = new myList();
}
} ///:~