I created two files in the same directory.
One is called VMAPI.java
package VMAPI;
public class VMAPI {
public VMAPI() {
System.out.println("Created VMAPI");
}
}
The other one is called Main.java and looks like this:
import VMAPI.VMAPI;
public class Main {
public static void main (String[] args){
VMAPI vmapi = new VMAPI();
}
}
I compile this using the command
javac *.java
And Run using
java Main
When I do, I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: VMAPI/VMAPI
at Main.main(Main.java:9)
Caused by: java.lang.ClassNotFoundException: VMAPI.VMAPI
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 1 more
I understand the error is telling me that it can't find the VMAPI class, but I don't understand why.
All I want to do is create maybe 2 or 3 classes for a very simple example use in my main function and that's it. I don't wan to use an IDE and want to compile, preferably with the command line.