0

I'm in /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

I run my program, but ClassNotFoundException is thrown.

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)

This is where the exception was thrown.

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

My code is not in any package.

My code runs in Eclipse. How can I make it run in cmd?

Gqqnbig
  • 5,845
  • 10
  • 45
  • 86

0 Answers0