Java – MAC terminal: unable to find or load the main class classname
I tried to run a java program through a terminal on a Mac, but I got:
Error: Could not find or load main class (MY CLASSNAME)
I compiled the application with eclipse, and when I ran it with eclipse, it worked properly In addition, I'm in the correct directory because when I type "LS" in the terminal, it lists all the files, including the class file I'm trying to run
This is what I entered:
java mainClass
I am very grateful to help solve this problem!
thank you,
dean
Edit: solution – instead of Java mainclass, it must also have a package: Java startpackage mainClass
Solution
First, make sure you are in the directory above the top-level package
If this category belongs to com foo. Bar package, you want to be located in the directory above com
In your case, you want to be located in the directory above the startpack
Then you need to run the class with a fully qualified name
java statPack.mainClass
For example