0. Installing the Java Development Kit (JDK) - Link
First, you need the Java Development Kit (JDK) from Oracle. This is the actual compiler that your development environment (IDE) uses behind the scenes. Even if you already have Java installed, you probably still need this. (Most people only have the Java Runtime Environment (JRE) installed, which allows you to run existing Java programs but not compile new ones.)- Windows
- Mac OS X
- Linux
- An Integrated Development Environment (IDE)
Direct your web browser to http://www.oracle.com/technetwork/java/javase/downloads/Click the big “Java Download” button above where it says “Java Platform (JDK) 7u21”, or any newer version if it’s newer.
You probably want the “Windows x86” version, which should be around 89 MB. Save this file in a location you can remember.Once downloaded, run the executable. Follow the prompts to install the JDK. You’ll need administrator access.Next, you’ll need to set an environment variable so that the command prompt can find the java compiler. You can find instructions for editing the PATH here.Once you’ve added Java’s bin folder to the PATH environment variable, you can try the Compiler Check assignment to make sure you’ve done it right.

screenshot of download button (The download button should look like this.)
1. Compiler Check - Link
This assignment is designed to make sure that the Java compiler (JDK) is correctly installed on your machine. Open a terminal window or command prompt. (In Windows XP or newer, Start Menu | All Programs | Accessories | Command Prompt) Then type, in order, the commands below.Success!
2. Compiling Practice - Link
This assignment is designed to give you practice compiling and running a Java program. Start by saving the following file to your CompSci folder. (You can save the file by right-clicking and choosing “Save Target As…” from the context menu.) Then open up a command prompt. Compile the program with the “javac” utility and then run the bytecode file through the “java” interpreter to execute it, as shown below.3. An Important Message - Link
This exercise will show you the detailed steps you must follow to create your first Java program. Launch Notepad. (Start Menu | All Programs | Accessories | Notepad) Then, type in the code listed below. Save your file as “FirstProg.java”.
Keep Notepad open; you will need it again if there are errors.
Open a command prompt. (Start Menu | All Programs | Accessories | Command Prompt) Then type, in order, the commands below.
4. A Good First Program - Link
- Task
- Question
Remember, you should have spent a good amount of time in the last assignment learning how to install a text editor, run the text editor, run a command prompt, and work with both of them. If you haven’t done that then don’t go on, you’ll not have a good time. This is the only time I’ll start an exercise with a warning that you should not skip or get ahead of yourself.Take the above and type in into a single file named GoodFirstProgram.java. This is important as Java works best with files ending in .java.Then, in a command prompt you compile the file by typing:If you did it right then nothing should happen. The computer will just skip a single blank line and display a prompt again. If not, then you’ve done something wrong. No, the computer is not wrong.Then, assuming there were no errors, you should run the program by typing:If you did it right then you should see the same output I have below. If not, then you’ve done something wrong.Sample Output:If your output is not exactly the same, then find out why and fix it. If you have an error it will look like this:It’s important you be able to read these since you’ll be making many of these mistakes. Even I make many of these mistakes. Let’s look at this line-by-line.
GoodFirstProgram.java
- Here we ran our command in the terminal to compiler the GoodFirstProgram java file.
- The Java compiler then tells us that the file GoodFirstProgram.java has an error on line 6.
- In this case, the specific error is that a semicolon was expected (’;’ expected)
- It then prints this line for us.
- Then it puts a ^ (caret) character to point at where it thinks the problem is. Notice that there is a colon (’:’) at the end of the line instead of a semicolon (’;’)
- Finally, it prints out the total number of errors. Usually the specific error messages are very cryptic, but if you copy that text into a search engine you’ll find someone else who’s had that error and you can probably figure out how to fix it.
5. Comments and Slashes - Link
- Task
- Question
Comments are very important in your programs. They are used to tell you what something does in English, and they also are used to disable parts of your program if you need to remove them temporarily. Here’s how you use comments in Java:From now on, I’m going to write code like this. It is important for you to understand that everything does not have to be literal. Your screen and program may visually look different, but what’s important is the text you type into the file you’re writing in your text editor. In fact, I could work with any text editor and the results would be the same.Sample Output:
CommentsAndSlashes.java
6. A Letter to Yourself - Link
- Task
- Answer
Write a program that displays your name and address on the screen as if it were a letter. Your output should look something like that below.Sample Output:
7. Your Initials - Link
- Task
- Answer
Display your initials on the screen in block letters as shown.Sample Output:In case you have no idea how to make a certain letter, there are some suggestions below.


8. Numbers and Math - Link
- Task
- Answer
- Question
Every programming language has some kind of way of doing numbers and math. Don’t worry, programmers lie frequently about being math geniuses when they really aren’t. If they were math geniuses, they would be doing math, not writing ads and social network games to steal people’s money.This exercise has lots of math symbols so let’s name them right away so you know what they’re called. As you type this one in, say the names. When saying them feels boring you can stop saying them. Here are the names:
- + plus
- - minus
- / slash
- * asterisk
- % percent
- < less-than
- > greater-than
- <= less-than-or-equal
- >= greater-than-or-equal