you must make sure that you add the location of your .class file to your class path. So, if you add it to the current folder. to your class path. Note that the window classpath separator is a semicolon, i.e.
javac -cp . PackageName/*.java java -cp . PackageName/ClassName_Having_main
An example . Suppose you have the following
then from the external directory:
$ cd src $ javac -cp . com/test/*.java $ java -cp . com/test/Hello
Note that you can add -d to specify the output directory of your class files at compilation
$ javac -d output_directory -cp . com/test/Hello
The windows will work the same too, I've already tried
Check out this from the official Oracle site.
source share