我正在尝试创建一个jar文件。它应该包含一个java主程序,它连接到jdbc并检索结果。
我尝试创建一个jar并成功创建jar但在运行时遇到了belw错误
**java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver**
文件夹结构:
D:project>myjar>com>java>test>util>MyJdbcProgram.class
D:project>myjar>com>java>test>util>ojdbc6.jar
Jar创建命令:
D:\project>jar cfe jdbctest-job.jar com.java.test.util.MyJdbcProgram -C D:\project\myjar .
D:\project>java -jar jdbctest-job.jar
main method
jdbctest method
trying to load class driver
oracle.jdbc.driver.OracleDriver
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
D:\project>jar -tf jdbctest-job.jar
META-INF/
META-INF/MANIFEST.MF
com/
com/java/
com/java/test/
com/java/test/util/
com/java/test/util/ojdbc6.jar
com/java/test/util/MyJdbcProgram.class
实际上哪里出错了?我正确地创建jar吗?为什么它没有找到ojdbc6?