經典問題,NoClassDefFoundError我需要什麼?創建新班級?經典錯誤,NoClassDefFoundError
import java.net.*;
import java.io.*;
import org.xsocket.*;
import org.xsocket.connection.*;
import java.io.IOException;
public class SocketClient {
public static void main(String[] args) {
try {
IBlockingConnection bc = new BlockingConnection("127.0.0.1", 8090);
String req = "Hello server";
bc.write(req + "\r\n");
} catch (IOException e){}
System.out.println("missing");
}
}
我得到以下異常:
C:\Users\Wildfire\Desktop>java -cp xSocket-2.8.14.jar SocketClient Exception in thread "main" java.lang.NoClassDefFoundError: SocketClient Caused by: java.lang.ClassNotFoundException: SocketClient 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) Could not find the main class: SocketClient. Program will exit.
什麼是完整錯誤? – TartanLlama 2010-11-04 16:23:05
哪個班級找不到?發佈異常跟蹤。 – AHungerArtist 2010-11-04 16:23:30
你使用的是notepad/vi嗎?一個合適的IDE應該只導入相關的類而不是'*'。檢查您的導入是否涵蓋您嘗試使用的所有課程。 (標準字符串除外) – Jimmy 2010-11-04 16:24:08