.java文件编译成.class文件的过程中出现的错误。如何解决?
源文件(.java)
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: ContentManager.java
package sztz.manage;
import java.sql.ResultSet;
import java.util.Vector;
import sztz.database.DBConnect;
import sztz.man.*;
import sztz.tool.Str;
public class ContentManager
{
String dbInfo;
public ContentManager()
{
}
public void insertContent(String contents[], Student am, int term, int style)
{
dbInfo = " ";
DBConnect dbc=null;
try
{
dbc = new DBConnect();
for(int i = 0; i < contents.length; i++)
if(contents[i].trim().length() != 0)
{
dbc.prepareStatement( "insert into s " + am.getCollege() + "(u_id,content,term,style) values(?,?,?,?) ");
dbc.setString(1, am.getID());
dbc.setString(2, Str.getStr(contents[i]));
dbc.setInt(3, term);
dbc.setInt(4, style);
dbc.executeUpdate();
dbInfo += "数据 " + Str.getStr(contents[i]) + " 插入成功 " + " <br> ";
}
}
catch(Exception e)
{
dbInfo = "插入数据失败 ";
e.printStackTrace();
}
finally
{
try
{
dbc.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
return;
}
............
在用“javac”命令编译后的错误提示:
^
ContentManager.java:26: cannot resolve symbol
symbol : class DBConnect
location: class sztz.manage.ContentManager
DBConnect dbc=null;
^
ContentManager.java:29: cannot resolve symbol
symbol : class DBConnect
location: class sztz.manage.ContentManager
dbc = new DBConnect();
^
ContentManager.java:35: cannot resolve symbol
symbol : variable Str
location: class sztz.manage.ContentManager
dbc.setString(2, Str.getStr(contents[i]));
^
ContentManager.java:39: cannot resolve symbol
symbol : variable Str
location: class sztz.manage.ContentManager
dbInfo += "数据 " + Str.getStr(contents[i]) + " 插入成功 " +
" <br> ";
^
ContentManager.java:65: cannot resolve symbol
symbol : class DBConnect
location: class sztz.manage.ContentManager
DBConnect dbc = null;
.........
[解决办法]
缺少需要的类库
[解决办法]
你是在ide里编译还是在 命令行里编译?
[解决办法]
交叉引用的时候必须同时编译
比如在A类中用到了B类,在B类中又用到了A类,A和B需要一起编译
如果不存在交叉引用,可以先编译那些独立的类
然后再编译引用独立类的那些类
[解决办法]
你直接javac *.java就可以了!!!!
[解决办法]
把你编译需要引入的类放到classpath下, 或者是你需要编译的文件得当前目录
[解决办法]
把你这个类DBConnect.java打成包.jar
放到lib下试试