当我尝试启动我们的 java 服务器时,我得到了这个:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
但是我在脚本所在的同一文件夹中有 mysql-connector-java-5.1.22-bin.jar,并在我运行脚本时进行此操作:
java -cp mysql-connector-java-5.1.22-bin.jar -jar AvatarServer.jar
但仍然得到这个。该怎么办?我正在使用 af CentOS 服务器。
root@host [/home/nagoom/Server_Example]# java -cp mysql-connector-java-5.1.22-bin.jar -jar AvatarServer.jar
************************
** FIRING UP SERVER! **
************************
Running MySQLChatMessageSaver
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at database.DatabaseConnection.connect(DatabaseConnection.java:13)
at items.ItemsDatabase.DownloadData(ItemsDatabase.java:35)
at items.ItemsDatabase.InitializeData(ItemsDatabase.java:24)
at network.SocketHandler.startListening(SocketHandler.java:84)
at server.AvatarServer.run(AvatarServer.java:44)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at database.DatabaseConnection.connect(DatabaseConnection.java:13)
at gameInstances.RoomController.DownloadRoomData(RoomController.java:46)
at gameInstances.RoomController.InitializeRooms(RoomController.java:32)
at network.SocketHandler.startListening(SocketHandler.java:85)
at server.AvatarServer.run(AvatarServer.java:44)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at database.DatabaseConnection.connect(DatabaseConnection.java:13)
at gameInstances.RoomController.LoadLockedSeatsForAll(RoomController.java:121)
at gameInstances.RoomController.InitializeRooms(RoomController.java:33)
at network.SocketHandler.startListening(SocketHandler.java:85)
at server.AvatarServer.run(AvatarServer.java:44)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at database.DatabaseConnection.connect(DatabaseConnection.java:13)
at gameInstances.RoomController.DownloadApartmentData(RoomController.java:89)
at gameInstances.RoomController.InitializeRooms(RoomController.java:34)
at network.SocketHandler.startListening(SocketHandler.java:85)
at server.AvatarServer.run(AvatarServer.java:44)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at database.DatabaseConnection.connect(DatabaseConnection.java:13)
at gameInstances.RoomController.LoadItemsForAllRooms(RoomController.java:160)
at gameInstances.RoomController.InitializeRooms(RoomController.java:35)
at network.SocketHandler.startListening(SocketHandler.java:85)
at server.AvatarServer.run(AvatarServer.java:44)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at database.DatabaseConnection.connect(DatabaseConnection.java:13)
at clothes.ClothesDatabase.DownloadGraphicsData(ClothesDatabase.java:42)
at clothes.ClothesDatabase.InitializeGraphics(ClothesDatabase.java:31)
at network.SocketHandler.startListening(SocketHandler.java:86)
at server.AvatarServer.run(AvatarServer.java:44)
MySQL exception: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
MySQL exception: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at database.DatabaseConnection.connect(DatabaseConnection.java:13)
at moods.MoodsDatabase.DownloadData(MoodsDatabase.java:29)
at moods.MoodsDatabase.InitializeData(MoodsDatabase.java:16)
at network.SocketHandler.startListening(SocketHandler.java:89)
at server.AvatarServer.run(AvatarServer.java:44)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at database.DatabaseConnection.connect(DatabaseConnection.java:13)
at robots.RobotHandler.downloadBots(RobotHandler.java:31)
at network.SocketHandler.startListening(SocketHandler.java:90)
at server.AvatarServer.run(AvatarServer.java:44)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at database.DatabaseConnection.connect(DatabaseConnection.java:13)
at levels.LevelDatabase.DownloadData(LevelDatabase.java:21)
at network.SocketHandler.startListening(SocketHandler.java:91)
at server.AvatarServer.run(AvatarServer.java:44)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at database.DatabaseConnection.connect(DatabaseConnection.java:13)
at network.SocketHandler.resetOnlineStatuses(SocketHandler.java:172)
at network.SocketHandler.startListening(SocketHandler.java:93)
at server.AvatarServer.run(AvatarServer.java:44)