This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm just trying to get everything ready on my mac so I can start programming in Java. It's supposed to already have the SDK, but I can't find the compiler. How do I find/run the compiler on the mac? Thanks.
Java should be ready to go on the Mac, so you shouldn't have to download, install, or configure anything.
Here are step-by-step instructions for Hello World on a Mac...
You can write Java code using TextEdit (Finder > Applications > TextEdit.app). When you launch TextEdit, the default is probably for Rich Text. Under the TextEdit's Format menu, select "Make Plain Text." Type the following code letter for letter (Java is case sensitive) in TextEdit...
From TextEdit's File menu, select Save As, and select a folder to save in. For the file name, type "HelloWorld.java" (without the quotes). When you save, TextEdit will ask if you want to use the .java extension instead of .txt. Use the .java extension.
Next open Terminal (Finder > Applications > Utilities > Terminal.app). At the prompt, use the command cd (change directory) to go to the folder where you saved HelloWorld.java. For example...
computerName:~ userName$ cd java/tests computerName:~/java/tests userName$
Next, compile your .java file by typing javac followed by a space and the file name (including the .java extension).
If the prompt returns without error, then the file has compiled. You will have a new HelloWorld.class file in the folder along with your original .java file. To run the .class file, type java followed by a space and the class name (without the .class extension). Your output should display on the following line.
computerName:~/java/tests userName$ java HelloWorld Hello World from a Mac!
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Hi! I was referred to this thread, and I successfully completed your instructions above (I have an intel iMac 2.4GHz) I, too, am brand-spanking new to this. I have the "Head First Java" book as well as the suggested "Just Java 2." I checked my version and have 1.6.0_21. Is there anything else I would need to get started? Thanks for any and all help you can give! I'm very anxious to get going but want to start out correctly...