I keep getting errors when I make my .class part of a package and try to run it from cmd.
Here\'s the code that works after using jav
The syntax is:
java -classpath /path/to/package-folder .
So you may try: java com.HelloWorld which would expect com/HelloWorld.class file to be present as classpath by default points to the current directory (if not specified).
In case you're in different folder, try specifying classpath:
$ CLASSPATH=/path/to/package-folder/ java com.HelloWorld
Hello World!
$ java -cp /path/to/package-folder/ com.HelloWorld
Hello World!
$ cd /path/to/package-folder/ && java com.HelloWorld
Hello World!
For further explanation, check: How do I run Java .class files?