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.
What exactly did you try when you say "tried"?
Usually you would do these
1) Compile with the javac command
2) Execute the code with the java command.
So which one is giving you problems? Also can you copy paste the exact command you are trying to use?
I saved it as "HelloWorld.java" onto my desktop/test folder. Then I use the javac command on the terminal. This is what the error looks like:
Heddys-MBP:~ hedz$ javac HelloWorld.java
javac: file not found: HelloWorld.java
I know I missed a critical step. Just don't know what
So to successfully run the javac command from anywhere, you need
Recommended reading: http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javac.html#examples
But when I type in the command: " java HelloWorld"I got this error:
Heddys-MBP:test hedz$ java HelloWorld.class
Error: Could not find or load main class HelloWorld.class
What did I do wrong?
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
Heddys-MBP:test hedz$ java HelloWorld
Error: Could not find or load main class HelloWorld
thanks for your patience
maneeshMac:test maneesh$ ls
maneeshMac:test maneesh$ java HelloWorld
Hello World from a Mac!
Initially I thought you might face a problem because of the upper case C in "Class" but then your compilation would have failed.
Anyone else got a clue?
PS. In the meanwhile since this is not a Mac problem, I will crosspost your topic to a more appropriate forum for you.
the problem is your class path does not contain a current directory as a source to read class files from there.so simply correct it and have fun.i am attaching a reference to 2 threads for making it simple for you,kindly go through both of these for the better understanding:
Hope it helps!!!