So I am trying to compile some java codes from the the terminal without eclipse.
I was following this tutorial
https://www.mkyong.com/java/java-rmi-hello-world-example/
So I got the 3 java files downloaded and I compiled them with
javac *.java
no error and I got 3 .class file
but when I ran
java ServerOperation
I got
Exception in thread "main" java.lang.NoClassDefFoundError: ServerOperation (wrong name: com/mkyong/rmiserver/ServerOperation)
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:442)
at java.net.URLClassLoader.access$100(URLClassLoader.java:64)
at java.net.URLClassLoader$1.run(URLClassLoader.java:354)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:312)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
I think I did not compile the files correctly but I don't know how to do it. what command should I use to compile?
update: Fixed after removing all the package declaration How do I mark this as resolved Special thanks to Tom for his useless comments