I'm trying to run a simple java program with terminal:
public class Test
{
public static void main(String...args)
{
System.out.println("Hello World");
}
}
So i compile using this command: javac Test.java
and this produces the binary file Test.class
.
When I try to run the program with java Test
I get this error:
Error: Could not find or load main class Test
Caused by: java.lang.ClassNotFoundException: Test
I don't know what to do anymore.
When I run echo $JAVA_HOME
I get the correct path:
/Library/Java/JavaVirtualMachines/jdk-13.jdk/Contents/Home
I also tried to run using java -cp /path-to-Test.class Test
and java .cp . Test
but those also didn't work.
The program is not in a package. The program is in the desktop folder in macOS. What can I do to solve this problem?