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
I have them both as part of my build path in t开发者_StackOverflow社区he project....I also added them both to my CLASSPATH environment variable...so the project runs perfectly when I use Eclipse's run button...
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:
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...
what did I do wrong?
You should not have a CLASSPATH environment variable.
A standalone JAR needs a MANIFEST that spells out the CLASSPATH. That's what the JDK is looking at, not your CLASSPATH environment variable.
Look at some tutorials showing how to do it. You'll have it running outside Eclipse in no time.
http://download.oracle.com/javase/6/docs/technotes/tools/solaris/jar.html
精彩评论