Back to 111 Main Page

Mobius strip

Assignment 0

Task

Get ready to program by writing a "Hello, World!" program on the same computer you plan to use to do your assignments.

Steps:

JDK

If you are planning to use your home machine, you will need to download and install the JDK. "JDK6 Update 4" is the latest version, but earlier versions will also work for this course. You do not need NetBeans (which is a large IDE program used when writing code), but you can get that version if you want to.

Hello, World!

Using Notepad or Wordpad, write a simple program, such as:

/**
 * My first program.  It prints a greeting to the screen.
 *
 * @author Zach Tomaszewski
 * @version 15 Jan 2008
 */
public class Hello {

  public static void main(String[] args) {
    System.out.println("Hello, World!");
  }

}

Compile this program at the command line: javac Hello.java

And then run it: java Hello

Remember that the class name must match the file name and that Java is case-sensitive.

What to Submit

All you have to send me is an short email saying you completed the above task--that you got Hello.java to compile and run on your machine. You do not need to send me any code or attachments.

Unrelated to the rest of this assignment, I need you to select a 2-digit number to use as your anonymous key for posting your grades online. (I will explain this more in lab.) You can either choose to use the last 2 digits of your lab account username, or else pick a number between 41 and 99, inclusive. Numbers 41-99 are assigned on a first-come, first-serve basis.

Grading

This assignment is worth 2 points of homework extra credit. Homework extra credit will boost your homework score average. However, it does not apply to other parts of the course. That is, your max homework average is 100%.

You get one point for successfully reporting that you got Hello, World to run. You get a second point for picking a grading key by the deadline for this assignment.

FAQs

When I try to compile, I get the following error: 'javac' is not recognized as an internal or external command, operable program or batch file.
This means that Windows cannot find the javac program. Normally when you download and install the JDK, it sets the path variable correctly. But occasionally it doesn't. Here's how to fix the problem.
  1. Find out where the javac.exe file was installed. It will probably be somewhere like C:\Program Files\Java\jdk1.6.0_04\bin\ (You might also try a file search for javac.exe if you can't find it by browsing.)
  2. Once you find javac.exe, type the full path on the command line, something like this:
      "C:\Program Files\Java\jdk1.6.0_04\bin\javac" Hello.java
    
    You need the quotes around the file path if it contains any spaces.
  3. If this works (Windows can now find javac), now you can update your path so you don't have to type the whole path name every time. These are the steps to do this in WindowsXP (some translation may be required for Vista):
    1. Go to Start -> Control Panel -> System. (It's easiest to find System when you change Control Panel to Classic View.)
    2. Go to the Advanced tab
    3. Click the Environment Variables button
    4. Scroll down through the System variables until you find Path.
    5. Edit this variable, adding C:\Program Files\Java\jdk1.6.0_04\bin\ to the end of the list. (Make sure there is a ; (semi-colon) between this path and the one before it.)
    6. Click OK for all of that, saving it all.
    7. Now open a new command prompt and see if just javac -version or javac Hello.java works, without the whole path.
If you ran into problems, let me know how far into this process you made it and what went wrong.


~ztomasze Index : TA Details: ICS111: Assignment 0
http://www2.hawaii.edu/~ztomasze
Last Edited: 15 Jan 2008
©2007 by Z. Tomaszewski.