在linux执行jar包找不到jdbc驱动?
我都把驱动放到classpath里了,还找不到驱动。。。
- Assembly code
echo $CLASSPATH/home/mps/java/jdk1.6.0_21/lib/ir.jar:/home/mps/java/jdk1.6.0_21/lib/tools.jar:/home/mps/java/jdk1.6.0_21/lib/rt.jar:/home/mps/java/jdk1.6.0_21/lib:.:/home/mps/liuhy/programs/mysql-connector-java-5.1.5-bin.jar
main方法在GetUserData里。执行的语句:
- Assembly code
java -cp getview.jar GetUserData
报错:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at GetUserData.main(GetUserData.java:27)
------解决方案--------------------
linux下的 ; 需要使用冒号格开,而不是分号