The root cause is CLASSPATH
Classpath is the path (or a bunch of paths) given to the JVM as probable locations where the required classes might be found. In addition to these, the JVM will also look in the current directory for the required classes (which explains why it runs from the current directory)
For more information, you can refer to
https://coderanch.com/how-to/java/HowToSetTheClasspath
Robert D. Smith wrote:(I only used the IDE for the syntax highlighting and having the error messages in the debug window)
I would say, getting rid of the IDE at a beginners stage is a very smart thing to do. In case you prefer highlighting (I agree, can be very useful) you might want to consider some advanced editors like
JEdit which can do the highlighting/indentation for you, but are not full blown IDEs (in the sense that they do things under the hood, things, which as a developer, you need to know)