Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Learn Java from the ground up

An introduction to Java that will help Java newbies to become Java developers

  • Print
  • Feedback

Page 2 of 6

That's about it on the JVM for now. If you want to know more, check out Sun's JVM specification in the Resources section below.

Setting up Java on your system

The first thing you need is the Java 2 Software Development Kit or SDK (formerly known as the Java Development Kit, or JDK). This is a set of software and software tools supplied by Sun that includes all of the basic components needed to build Java programs. If you don't have this, you'll need to download the Java 2 SDK from Sun (see Resources below). Here's a brief description of what you need to do to install version 1.2.x for the Windows platform:

  • For Windows, the download will be a self-extracting archive, and the file name follows the form: jdk<version>-win.exe. For example, for version 1.2.2, the file is named jdk1_2_2-win.exe.
  • Execute the program to install the Java 2 SDK.
    • You can execute it by typing its name at a command prompt.
    • You can double-click it from Explorer.
    • On Windows, the default installation directory is C:\JDK1.2.x


  • You must set up your environment correctly
  • Your path must be set to include the bin subdirectory
  • For example, if you installed the Java 2 SDK in C:\JDK1.2.x, you must include C:\JDK1.2.x\bin in your path
    • If you are using Windows 95/98, you can do this in autoexec.bat
    • If you are using Windows NT, go to Control Panel, System, Environment
    • You can set environment variables in the dialog box there
  • There are other parts of the environment that are important, especially the CLASSPATH environment variable. I'll discuss this in future columns.


  • It's also important to download the javadoc HTML documentation for the core API classes. This is a separate download, in zip format, and the filename is in the form of jdk<version>-doc.zip (for example, jdk1_2_2-doc.zip).
  • The javadoc HTML documentation should be unzipped into the Java 2 SDK installation directory
    • Note that the zip file has a directory structure within it, so that unzipping it into C:\ will place all of the files at the root directory C:\JDK1.2.x\docs, which is a good place for them.


The following tools will be used to create and run our first program:

  • javac: the Java compiler that converts Java source to bytecode
  • java: the Java Virtual Machine


How to write a Java program

OK, it's time to write our first Java program. A Java program looks like this:

public class MyProgram {

public static void main(String[] args) { System.out.println( "Eureka, I can put Java on my resume."); } }


A Java program is a class with a main method in it. The main method is a special method that is the starting point for every Java application. It has to be declared exactly as above, and it has to appear within a class, as the above example also shows. System.out.println is the magic incantation you use to get things sent to the console.

This code example is for a standalone, nongraphical Java program that prints the string Eureka, I can put Java on my resume. to the console. Your salary can double now, so if you want, you can stop here. Those that want to learn more can keep going.

  • Print
  • Feedback

Resources