Hi. Im new to JAVA and Im currently reading the book Head First Java. I have installed java 8 in my Mac (macOS Sierra 10.12). I tried the HelloWorld example but it says "file not found." I used textedit and saved it as "HelloWorld.java" on my desktop under test folder.
Navigate to where the class file is located
cd ~/Desktop/test
Now run java HelloWorld
Note: You should NOT give the .class extension to this command.
The problem is the JVM does not know where your class files are. So you navigate to the directory where they are located (cd ~/Desktop/test) and then execute them.
To simplify this process you can set the class path (path at which the JVM can expect to find class files)
More on it here
https://coderanch.com/wiki/660138/Set-Classpath
I change the path using cd ~/desktop/test. So I am now on the directory where my HelloWorld.class file is at. Still when I enter the code "java HelloWorld" I encounter the same problem
Heddys-MBP:test hedz$ java HelloWorld
Error: Could not find or load main class HelloWorld
Heddys-MBP:test hedz$