在cmd中运行它时的`java.lang.ClassNotFoundException`

时间:2014-03-07 00:18:40

标签: java

我在/Users/gqqnbig/SourceCode/Java/PlayerStatisticReader/bin

Macintosh:bin gqqnbig$ ls
BasketballRules.class           PlayerGameStatistic.class
BuildMode.class             PlayerQuarterStatistic.class
EspnGameRecord.class            PlayerStatistic.class
GamePartiesData.class           Program.class
GameParty.class             mysql-connector-java-5.1.29-bin.jar

我运行我的程序,但是ClassNotFoundException被抛出。

Macintosh:bin gqqnbig$ java  Program
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:190)
    at Program.main(Program.java:33)

这是抛出异常的地方。

Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/NBA", "root", "");

我的代码不在任何包中。

我的代码在Eclipse中运行。如何让它在cmd中运行?

0 个答案:

没有答案