当前位置: 技术问答>java相关
cannot access ConnPool? bad class file:.\ConnPool.class?
来源: 互联网 发布时间:2017-03-30
本文导语: 我编写了两个类文件ConnPool.java和SqlBridge.java,并存在同一文件夹下,程序如下: 1、ConnPool.java package mybeans.bookstore; import java.lang.*; import java.sql.*; import java.util.*; import javax.servlet.*; public class ConnPool{ .... } 2、SqlBridge.j...
我编写了两个类文件ConnPool.java和SqlBridge.java,并存在同一文件夹下,程序如下:
1、ConnPool.java
package mybeans.bookstore;
import java.lang.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
public class ConnPool{
....
}
2、SqlBridge.java
package mybeans.bookstore;
import java.lang.*;
import java.sql.*;
import javax.swing.*;
import javax.servlet.*;
public class SqlBridge{
private Connection conn;
private ResultSet rs;
private ResultSetMetaData rsmd;
private Statement stmt;
private String driverName;
private String jdbcURL;
private String username;
private String password;
private ConnPool connPool;
}
ConnPool.java顺利编译通过,但是编译SqlBridge.java时,却出现如下错误:
SqlBridge.java:17: cannot access ConnPool
bad class file: .ConnPool.class
class file contains wrong class: mybeans.bookstore.ConnPool
Please remove or make sure it appears in the correct subdirectory of the classpath.
private ConnPool connPool;
^
1 error
这是怎么回事,大家帮忙呀,谢谢
1、ConnPool.java
package mybeans.bookstore;
import java.lang.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
public class ConnPool{
....
}
2、SqlBridge.java
package mybeans.bookstore;
import java.lang.*;
import java.sql.*;
import javax.swing.*;
import javax.servlet.*;
public class SqlBridge{
private Connection conn;
private ResultSet rs;
private ResultSetMetaData rsmd;
private Statement stmt;
private String driverName;
private String jdbcURL;
private String username;
private String password;
private ConnPool connPool;
}
ConnPool.java顺利编译通过,但是编译SqlBridge.java时,却出现如下错误:
SqlBridge.java:17: cannot access ConnPool
bad class file: .ConnPool.class
class file contains wrong class: mybeans.bookstore.ConnPool
Please remove or make sure it appears in the correct subdirectory of the classpath.
private ConnPool connPool;
^
1 error
这是怎么回事,大家帮忙呀,谢谢
|
if compile under
XX/mybeans/bookstore/
type
javac -classpath ../../ SqlBridge.java ConnPool.java
XX/mybeans/bookstore/
type
javac -classpath ../../ SqlBridge.java ConnPool.java
|
d:tempweb-infclassesmybeansbookstorejavac SqlBridge.java
改成
d:tempweb-infclassesmybeansbookstorejavac -classpath ../../ SqlBridge.java
有沒有看打了 "-classpath ../../ "
改成
d:tempweb-infclassesmybeansbookstorejavac -classpath ../../ SqlBridge.java
有沒有看打了 "-classpath ../../ "
|
> public class SqlBridge extends ConnPool
不要相信他, 和extend 沒有关系
>存在同一文件夹下
文件夹的名字是什么?
要
xxx/mybeans/bookstore/SqlBridge.class
xxx/mybeans/bookstore/ConnPool.class
不要相信他, 和extend 沒有关系
>存在同一文件夹下
文件夹的名字是什么?
要
xxx/mybeans/bookstore/SqlBridge.class
xxx/mybeans/bookstore/ConnPool.class
|
import java.lang.*;
import java.sql.*;
import javax.swing.*;
import javax.servlet.*;public class SqlBridge extends ConnPool
{
..........
}
哎,你是个百分百的初学者啊!
import java.sql.*;
import javax.swing.*;
import javax.servlet.*;public class SqlBridge extends ConnPool
{
..........
}
哎,你是个百分百的初学者啊!