我在/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中运行?