当前位置: 技术问答>java相关
这怎么能cannot resolve symbol?
来源: 互联网 发布时间:2017-04-14
本文导语: 我写了两个.java文件SqlBridge.java和LoginUser.java,代码如下: //Sql_Bridge.java package mybeans.bookstore; import java.lang.*; import java.sql.*; import javax.swing.*; import javax.servlet.*; public class SqlBridge{ private Connection conn; private...
我写了两个.java文件SqlBridge.java和LoginUser.java,代码如下:
//Sql_Bridge.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;
}
//LoginUser.java
package mybeans.bookstore;
import java.sql.*;
public class LoginUser
{
private boolean isMember;
private boolean checked;
private String id="";
private String password="";
private SqlBridge sqlBridge;
}
并都存在d:classesmybeansbookstore下,
我用d:classesmybeansbookstorejavac SqlBridge.java顺利编译通过,但当我
用d:classesmybeansbookstroejavac LoginUser.java时却报错:
LoginUser.java:10:cannot resolve symbol
symbol:class SqlBridge
location: class mybeans.bookstore.LoginUser
private SqlBridge sqlBridge;
1 error
//Sql_Bridge.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;
}
//LoginUser.java
package mybeans.bookstore;
import java.sql.*;
public class LoginUser
{
private boolean isMember;
private boolean checked;
private String id="";
private String password="";
private SqlBridge sqlBridge;
}
并都存在d:classesmybeansbookstore下,
我用d:classesmybeansbookstorejavac SqlBridge.java顺利编译通过,但当我
用d:classesmybeansbookstroejavac LoginUser.java时却报错:
LoginUser.java:10:cannot resolve symbol
symbol:class SqlBridge
location: class mybeans.bookstore.LoginUser
private SqlBridge sqlBridge;
1 error
|
最好编译时
javac -classpath %主页目录WEB-INFclasses%
javac -classpath %主页目录WEB-INFclasses%
|
class路径设置不正确
|
应该退出到包外编译,
cd d:classes
d:classes javac -classpath . bybeans/bookstore/*.java
处在同一包同一层的class之间不需要相互import
cd d:classes
d:classes javac -classpath . bybeans/bookstore/*.java
处在同一包同一层的class之间不需要相互import