Good evening!

There is a problem with Ubuntu. When you run any .class file produces a similar error:

Exception in thread "main" java.lang.NoClassDefFoundError: src/ua/nure/shylin/socketclientserverpack/ServerPart (wrong name: ServerPart) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:803) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) 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 sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) 

The error is about the same for any files, only the path changes. From Windows everything works fine.

The code I'm trying to run in this case:

 public class ClientPart { static Socket fromServer; static final String HOST = "localhost"; static final int PORT = 4444; static BufferedReader in; static BufferedReader usersMessage; static PrintWriter out; public static void main(String[] args) throws IOException { System.out.println("Welcome to Client side, dude"); System.out.println("Connection to\nhost: " + HOST + "\nport: " + PORT + "\n"); fromServer = new Socket (HOST, PORT); in = new BufferedReader(new InputStreamReader(fromServer.getInputStream())); usersMessage = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(fromServer.getOutputStream(), true); String fuser, fserver; while ((fuser = usersMessage.readLine())!=null) { out.println(fuser); fserver = in.readLine(); System.out.println(fserver); if (fuser.equalsIgnoreCase("close")) break; if (fuser.equalsIgnoreCase("exit")) break; } out.close(); in.close(); usersMessage.close(); fromServer.close(); } } 

Thank you for your help!

  • Most likely I am wrong, but check case-sensetive and Cyrillic en route - Leonid Lunin
  • @LeonidLunin In theory, in the case of an incorrect path, it writes something like Could not find or load it main main class <path> - OldNo7
  • So here about the same. He did not find the class. Can you show a piece of code with a call to this class? MB there is something ... - Riĥard Brugekĥaim
  • @ RiĥardBrugekĥaim Added to the header. But I doubt that this is due to the code: it gives an error even when I try to run something like System.out.println ("Hello World!"); - OldNo7

0