Skip To Content

School of Computing and Information Systems

Java Help

Getting Started with Java

  1. The first thing you will need to do, before you get started on your course, is to download your Java compiler. For most courses, you'll need the full Java Standard Edition Java Development Kit (JDK). This download also includes the JRE:
    • These instructions are now for the latest Java installation - JDK 6..
    • Java SE (Standard Edition) Downloads - Go to 'Java SE Development Kit (JDK)' box and select the 'Download' button. (This is supported for Windows 2000, XP, and Vista, as well as Linux and Solaris operating systems. For Macs, see Step 7 below.)
  2. Once you have downloaded the JDK into a folder on your harddrive, go to that folder and double click on the file named (for example) jdk-6u13-windows-i586-p.exe to install it (version number may vary). Note: This is assuming you are installing this file on a Windows machine. Double clicking on the file will start the JDK Installer, then follow the instructions the installer provides.
  3. The installer will create a new directory named (for example) C:\Program Files\Java\jdk1.6.0_13. Inside this new folder are a group of folders and files. You will need to set the path to this so that your computer can find the right programs required to compile and run your java programs. Setting Your Path for the JDK
  4. The JDK does not provide an editor or any program icons to run them with. You have several options for creating, compiling, and running your Java programs:
  5. Java Sun Tutorial for compiling first Java program in DOS
  6. Java Sun Common Java Compiler Errors and Solutions
  7. If you encounter problems downloading or installing the JDK, contact the Virtual Helpdesk.
  8. Tips for Compiling and Running Programs
  9. Java for Mac OS X
  10. Your First Cup of Java (for Windows, Linux, and Mac OS)

Java Path

Choose the operating system you use:
  1. Click Start, Control Panel, and then double click on the System icon.
  2. Click the Advanced Tab at the top of the Window, and then click Environment Variables.
  3. In the System Variables box, find the PATH statement, click once to highlight it and choose it, then click the "Edit" button.
  4. Add your SDK path to the end of the existing path statement preceded by a semi-colon as shown below: C:\Program Files\Java\jdk<version>\BIN Where <version number> is replaced by the current numerical version number.
  5. Click OK, click OK and click Ok again. Reboot your computer.

Windows 7
  1. Click "Windows Explorer" or right Click the "Start or Windows icon" and then select "Explore"
  2. Right click on the "Computer" located above the "C:"
  3. Click Change Settings, then select to Continue on the warning screen
  4. Click the Advanced Tab, then select Enviroment Variables
  5. Scoll down to the Path Variable
  6. Click Edit and modify as for Windows XP, then restart your computer.

Windows Vista
  1. Click the Windows icon for the Start Menu, then click Control Panel
  2. Click System Maintenance, then select System
  3. Click Change Settings, then select to Continue on the warning screen
  4. Click the Advanced Tab, then select Enviroment Variables
  5. Scoll down to the Path Variable
  6. Click Edit and modify as for Windows XP, then restart your computer.

To run the java compiler for Windows 98, Windows ME, Windows NT, you must have "C:\j2sdk1.5_<version_number>\bin" (or whatever folder you have your SDK files in, for example c:\j2sdk1.5\bin ) in your path. To do this, choose the operating system you are using from the above list and follow the subsequent directions.
Windows ME From the start menu, choose programs, accessories, system tools, and system information. This brings up a window titled "Microsoft Help and Support". From here, choose the tools menu, then select the system configuration utility. Click the environment tab, select PATH and press the edit button. Now add the SDK directory location to your path. If you are not sure where to add the path, add it to the right end of an existing path statement preceded by a semi-colon. Below is an example where the SDK bin directory has been added to an existing path statement containing the WINDOWS and WINDOWS\COMMAND directories. PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:\J2SDK1.4.1_(version number)\BIN The (version number) will vary depending on the latest version available from Sun. After you've added the location of the SDK to your PATH, save the changes and reboot your machine when prompted.
Windows NT and Windows 2000
  1. Start the Control Panel, select System, on NT select the Environment tab and in 2000 select the Advanced tab and then "Environment Variables. Look for "Path" in the User Variables and System Variables. If you're not sure where to add the path, add it to the right end of an existing path statement preceded by a semi-colon in the User Variables. A typical value for PATH is: C:\J2SDK1.4.1_<version number>\BIN Click "Set", "OK", or "Apply".
  2. The new path takes effect in each new DOS Prompt window you open after setting the PATH variable.

Windows 98 *NOTE* All references to <version number> below refers to the current numerical version number of the SDK. Thus, understand this may change, at the time of this writing it is 01.
  1. Start the system editor by clicking on the START button, choose RUN and enter sysedit and click OK. Choose the window that is named AUTOEXEC.BAT.
  2. In the AUTOEXEC.BAT file, you may already have a "PATH" line in the form PATH= ... ; ... (Where ... ; ... represents other possible entries in the PATH. The PATH can be a series of directories separated by semi-colons (;). Windows looks for programs in the PATH directories in order, from left to right.) For example, in the following PATH statement we have added a new entry for the Java 2 SDK (shown in bold). PATH = C:\WINDOWS;C:\WINDOWS\COMMAND;C:\J2SDK1.4.1_01\bin If you do not have an existing PATH staement then create a line that says the above (eg. PATH=C:\J2SDK1.4.1_01\bin). The above assumes that the JDK is installed to the C drive under a directory called \J2SDK1.4.1_01. Check where the SDK is installed on your computer.
  3. You have to reboot your computer before these changes take place.
  4. Note: If you email the Virtual Helpdesk for assistance in setting your path, do NOT send your AUTOEXEC.BAT file as an email attachment, as AU email filters will block that file extension type. Instead, just copy and paste the file contents into your email message.


Running the JDK from the MS-Dos Prompt

  1. To compile a java progam, save it in a file in your working directory. For example if the program is Program1 (with the main class within the program named Program1), save it as If using Notepad as your editor ensure that the java file you created does not have the "txt" extension added to the end of the file, otherwise, it will not compile. Then go to a DOS prompt and compile the program with
  2. To run the program, after compilation type
    java Program1
    at the DOS prompt.
  3. To run an applet, which has to be viewed using an HTML document (ie. applet.htm), type
    appletviewer applet.htm
    at the DOS prompt.
  4. To run DOS as a window Instead of as full screen, select the DOS icon (look under C:\WINDOWS\Start Menu\Programs) and click on the right mouse button. Select Properties. Select Screen. Change from Full-screen to Window.
  5. Java Sun Tutorial for compiling first Java program in DOS
  6. Java Sun Common Java Compiler Errors and Solutions

Running the JDK using the Programmer's File Editor

This program provides a few basic options to help you develop your java programs using the JDK. (You must first have Java 2 SDK or JDK 1.1 installed). One of its biggest advantages is that it is completely free.

  1. If you haven't already done so, download the Programmer's File Editor. Unzip it to the folder of your choice.
  2. Click on the Pfe32 icon in that folder, to open up the program. It would be a good idea to create a shortcut to that file.
  3. This program runs much like any other windows editor. Go to "file", then "new" or "open" to open a file. You have editing options available similar to notepad or wordpad. All files are saved in text format. You have to choose the file extension name you wish to save it as (ie - .java or .htm).
  4. To compile or run your program, go to "Execute", select the "Dos Prompt", and proceed in the same way you would with Running the Java 2 SDK using MS-Dos. Program and error output appear in the MS-Dos window.

Running the JDK using JCreator

This program provides many options to help you develop your java programs using the JDK. (You must first have Java 2 SDK installed). JCreator is freeware.

  1. If you haven't already done so, go to The JCreator Home Page and download the latest version of JCreator. Click on this file to extract and install it. This will create an icon in your start-up menu and on your desktop.
  2. When you first open the program, you will be prompted to enter in path to your JDK directory and the JDK documentation directory. You can browse for these directories. You will need to install the JDK Documentation files separately (from the JDK site), if you wish to have the help files in place.
  3. JCreator opens up in 3 sections and includes a FileView, Class View and an Output View. The main section is the edit window. Open your program files in the same way as in any windows editor - "File" then "New" or "Open". The edit window color codes the source code - green for comments, blue for reserved words, etc..
  4. The Class browser windows enables you to navigate through the Java classes of your application. It displays the project items of the project workspace and its classes as an expandable file tree.
  5. The Output View displays the output messages of the tools and the search engine.
  6. To compile a file, from the Menu at the top, click on Build, Compile File. This will start the java compiler and will compile the active file. If you want to Execute the file, from the menu at the top, click on Build, Execute File. This will execute the active file.
  7. At the bottom of the screen, you have an Build/Output windows. Within the windows there are some tabs. A Build tab and an Output tab. When you compile a file, messages will appear here in the Build tab. When you run the file, clicking on the Output tab will display the program's output.
  8. JCreator has a comprehensive help system included within the program, which you can access by clicking Help from the bar at the top.


This is a system variable that defines the root for the source of classes. It operates like a path variable. For example, when you set: CLASSPATH=.;E:\JDK1.2.2\BIN\..\CLASSES; You are telling the compiler where to find the root directory of built-in class libraries. The starting '.' is necessary to instruct the machine to use the current directory as a CLASSPATH, as well. Normally the CLASSPATH does not need to be set, unless another program has set one and then you need to be sure that it has included the current path as above. Note that setting the CLASSPATH is different from setting the PATH, (for example PATH=E:\JDK1.2.2\BIN\) which is the path to the binaries java and javac.


A package is a library of classes all in the same subdirectory. You can also put source files and anything else in that subdirectory and compact the whole thing into a .zip or .jar file. When you, as a programmer, want to build a library you include a package statement in the program before the first source line e.g. package comp308.program1 if the root of your classpath goes to ..myprograms\ then the compiler will put the class files in myprograms\comp308\program1. You will need to do this for all the source files that make up the package. When you compile your program with javac the compiler will expect to find all the source files and will put all the class files in myprograms\comp308\program1. When you run your program with java you must indicate the package as well as the class. The interpreter will look for the class files by following the classpath to its root and then adding the package pathing. For example, in the situation above, if your main() is in Class1, to run Class1.class type: java comp308.program1.Class1

Computer Programming in Java

  1. Make sure that you edit the Java source code of every class you design in a SEPARATE FILE, and that the name of that file has the ".java" extension.
  2. Make sure that name of every Java source code file (not counting the ".java" extension) MATCHES EXACTLY the name of the class defined in that file.
    • for example if the class name of the first Java source code that you need to compile is called Program1. You will need to save this file as Ensure that you preserve the capital letter, as the Java compiler is case-sensitive.
  3. For more help in using the JDK, go to the JDK Help Files

Last Updated April 07, 2011