This quick tutorial will show you how to create a file, compile, and run it from the command-line. We will use the "nano" editor in this tutorial. You will need a Mac to do this tutorial. 1. Open the Terminal application on your Mac. When I open mine, I see: Last login: Mon Feb 6 14:54:25 on ttys002 $ (your "prompt" may look a little different--that's OK) 2. Let's "change directory" to your Desktop. At the "$" prompt, type (don't type the $): $ cd ~/Desktop 3. Create a folder called "HowToCompile". $ mkdir HowToCompile (you should see this folder appear on your Desktop) 4. Go into the "HowToCompile" folder: $ cd HowToCompile 4. Create two more folders inside "HowToCompile" called "src" and "bin". $ mkdir src $ mkdir bin 5. We're going to use the "nano" editor now to create a file inside the "HowToCompile/src" folder: $ nano -w src/HelloWorld.java 6. You are now running the "nano" program. At the top of your screen, you should see: GNU nano 2.0.6 File: src/HelloWorld.java and at the bottom of the screen, you should see: [ New File ] ^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos ^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut Text ^T To Spell 7. The "^" symbol stands for the "control key." So if you press Ctrl-x, you will Exit the program. Try it now. Press Ctrl-x. 8. You should be back at the command-line prompt (the $). 9. Start nano again: $ nano -w src/HelloWorld.java 10. But this time, highlight the following source code, copy it using Command-C, and then paste it into nano using Command-V. public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world!"); } } 11. Now press Ctrl-x. But notice that since you put text in the window, nano will ask you if you want to save. You should see the following at the bottom of your screen: Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ? Y Yes N No ^C Cancel 12. Press the 'y' key. 13. nano will now ask you what you want to call the file: File Name to Write: src/HelloWorld.java ^G Get Help ^T To Files M-M Mac Format M-P Prepend ^C Cancel M-D DOS Format M-A Append M-B Backup File 14. Press the "return" key to accept the name as-is ("src/HelloWorld.java"). 15. You should be back at the command prompt ($) again. Now, let's compile our Java file in src using javac and make sure that the compiled class file goes into bin: $ javac -d bin src/*.java 16. Notice now if we "list" the contents of the bin directory, we should see our HelloWorld.class file: $ ls -al bin total 8 drwxr-xr-x 3 dbarowy staff 102 Feb 6 15:09 . drwxr-xr-x 5 dbarowy staff 170 Feb 6 15:00 .. -rw-r--r-- 1 dbarowy staff 426 Feb 6 15:09 HelloWorld.class 17. Let's run the program now. $ java -cp bin HelloWorld Hello world!