So the problem is probably some wrong setting in Eclipse or a different directory structure than what Eclipse expects. My directory structure in the shell snippet is plain java with a directory for each part of the package name (separated by a dot). Java's classpath needs to be set to the current directory, so that it can find the Main class (-cp .). But your Eclipse project has at least an additional src directory as entry point. When I start new java projects I use maven or gradle and follow their directory structure, which also have your srcdirectory, but additionally a main and a java directory. Then I can use any Java IDE, because they all support maven's directory structure.
P.S.: Actually you don't need -cp, yet, as long as you've got a single .java file only.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In such a case I try to run things from the command line. And it works:
So the problem is probably some wrong setting in Eclipse or a different directory structure than what Eclipse expects. My directory structure in the shell snippet is plain java with a directory for each part of the package name (separated by a dot). Java's classpath needs to be set to the current directory, so that it can find the Main class (
-cp .
). But your Eclipse project has at least an additionalsrc
directory as entry point. When I start new java projects I use maven or gradle and follow their directory structure, which also have yoursrc
directory, but additionally amain
and ajava
directory. Then I can use any Java IDE, because they all support maven's directory structure.P.S.: Actually you don't need
-cp
, yet, as long as you've got a single.java
file only.