简体   繁体   English

jdbc 不在类路径错误中

[英]jdbc not in classpath error

so I have a project that requires Weka machine learning library (weka.jar) and the mysql jdbc mysql-connector-java-5.1.17-bin.jar所以我有一个项目需要 Weka 机器学习库 (weka.jar) 和 mysql jdbc mysql-connector-java-5.1.17-bin.Z68995FCBF432492D15484D04A9D2AC4

I have them both as part of my build path in the project....I also added them both to my CLASSPATH environment variable...so the project runs perfectly when I use Eclipse's run button...我将它们都作为项目中构建路径的一部分......我还将它们都添加到了我的 CLASSPATH 环境变量中......所以当我使用 Eclipse 的运行按钮时项目运行完美......

but then after exporting the project as a standalone jar and run the java -jar theproject.jar command, it returns a whole bunch of errors:但是在将项目导出为独立 jar 并运行 java -jar theproject.jar 命令后,它返回一大堆错误:

Trying to add database driver (JDBC): RmiJdbc.RJDriver - Error, not in CLASSPATH
?
Trying to add database driver (JDBC): jdbc.idbDriver - Error, not in CLASSPATH?
Trying to add database driver (JDBC): com.mckoi.JDBCDriver - Error, not in CLASS
PATH?
Trying to add database driver (JDBC): org.hsqldb.jdbcDriver - Error, not in CLAS
SPATH?
java.sql.SQLException: No suitable driver found for jdbc:idb=experiments.prp
java.lang.IllegalStateException: Not connected, please connect first!

even though it ran perfectly on eclipse and despite the fact that both weka.jar and mysql-connector-java-5.1.17-bin.jar are in the CLASSPATH environment variable...即使它在 eclipse 上完美运行,尽管 weka.jar 和 mysql-connector-java-5.1.17-bin.jar 在 CLASSPATH 环境中都是变量...

what did I do wrong?我做错了什么?

You should not have a CLASSPATH environment variable.您不应该有 CLASSPATH 环境变量。

A standalone JAR needs a MANIFEST that spells out the CLASSPATH.独立的 JAR 需要一个说明 CLASSPATH 的清单。 That's what the JDK is looking at, not your CLASSPATH environment variable.这就是 JDK 所关注的,而不是您的 CLASSPATH 环境变量。

Look at some tutorials showing how to do it.查看一些教程,展示如何做到这一点。 You'll have it running outside Eclipse in no time.你很快就会让它在 Eclipse 之外运行。

http://download.oracle.com/javase/6/docs/technotes/tools/solaris/jar.html http://download.oracle.com/javase/6/docs/technotes/tools/solaris/jar.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM