gpt4 book ai didi

java - Derby 和 eclipse 。 "Can' t find main"异常。如何将Derby添加到配置类路径?

转载 作者:行者123 更新时间:2023-11-30 04:02:27 24 4
gpt4 key购买 nike

我正在尝试根据 this guide 在 eclipse 上安装 derby

我的$CLASSPATH:

/opt/Apache/db-derby-10.10.1.1-bin/lib/derby.jar:/opt/Apache/db-derby-10.10.1.1-bin/lib/derbytools.jar

我还通过项目属性将其添加到 Java 构建路径中。现在每当我运行我的程序时,它都会说:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/derby/impl/tools/sysinfo/Main
Caused by: java.lang.ClassNotFoundException: org.apache.derby.impl.tools.sysinfo.Main

有什么解决办法吗?我的代码:导入java.sql.Connection;导入 java.sql.DriverManager;导入 java.sql.PreparedStatement;导入java.sql.ResultSet;导入java.sql.SQLException;导入java.sql.Statement;

导入java.util.ArrayList;导入java.util.Properties;

public class Sample2 {

public static void main(String[] args) {
System.out.println("POOP");
new Sample2().go(args);
System.out.println("SimpleApp finished");


}
void go(String[] args){
Connection conn = null;
ArrayList statements = new ArrayList();
PreparedStatement psInsert = null;
PreparedStatement psUpdate = null;
Statement s = null;
ResultSet rs = null;
String dbName = "Lab4DB";
try {
conn = DriverManager.getConnection(protocol + dbName);
System.out.println("Connected to and created database " + dbName);
conn.setAutoCommit(false);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
private String framework = "embedded";
private String driver = "org.apache.derby.jdbc.EmbeddedDriver";
private String protocol = "jdbc:derby:";
}

enter image description here

最佳答案

右键单击您的项目运行方式 > 运行对话框 > 类路径选项卡,然后通过单击添加外部 jar 添加 derby.jar 、 derbynet.jar 和 derbyclient.jar

这三个jar文件可以在从apatche DB下载的文件夹中找到它们

关于java - Derby 和 eclipse 。 "Can' t find main"异常。如何将Derby添加到配置类路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21645978/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com