I am trying to run a java program through the Terminal on Mac, yet getting:
Error: Could not find or load main class (MY CLASSNAME)
I compiled this application with Eclipse, and when I run this with Eclipse, it works fine. Furthermore, I am in the right directory, as when I type "ls" in the Terminal, it lists all the files, includes the class file I am trying to run.
This is what I type:
java mainClass
I would very much appreciate help to solve this!
Thank you,
Dean
EDIT: Solution - instead of java mainClass, it must have package too: java startPackage.mainClass
Problem: Error "Could not find the main class - program will exit" on the ServiceDesk configuration while configuring Web Services. Cause: This happens when there are multiple java versions installed and the value of NtfsDisable8dot3NameCreation is incorrectly set.
Start by making sure you are at the directory above the top level package
If the class belongs to the package
com.foo.bar
, you want to be in the directory above com
.
In your case, you want to be in the directory above startPack
.
Then you need to use the fully qualified name to run the class...
java statPack.mainClass
For example...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With