Java Tutorial/Installing Java

The first thing we need to do before we can learn Java is to install the software needed to develop and run Java programs. Most people have the Java Runtime Environment installed on their computer to be able to run Java programs; since we're planning on writing Java code, however, we need the Java Development Kit (JDK). The JDK includes command-line development tools such as the Java compiler that are essential in your program development, as well as the JRE (you don't need to download the JRE if you download the JDK).

Both the JRE and JDK can be downloaded at here. Other downloads such as patches, source code, and documentation can also be found at the link mentioned.

Software Prerequisites
Name Description
Java Runtime Environment (JRE) Allows users to run Java programs/applets; unnecessary if downloading the JDK
Java Development Kit (JDK) Contains development tools e.g compilers, etc; also bundles JRE

You may notice that there are multiple download choices for the JDK; for the present, just download the Standard Edition. Installing Java in the default directory is highly recommended as it simplifies the next part of the process. Detailed installation notes for a variety of platforms can be found in the Java SE Documentation; the following only applies to Windows users:

After installing the JDK, we need to do a little fiddling with a thing called an environment variable before you can conveniently develop with it. The variable we are going to edit are PATH (used by the Windows to locate executable files) and CLASSPATH (used by the Java Virtual Machine and Java technology-based applications to locate .class files).

To Get to the Environmental Variables Dialog:

  1. Click the Start button
  2. Right-click My Computer, and click Properties
  3. Click the Advanced tab, and click on Environment Variables

Now, assuming you looking at the User Variables list-box:

  • If there is not a variable named PATH:
    • Click New
    • Enter PATH as the variable name, and enter the path of the \bin directory in your Java installation as the value, followed by a semi-colon.
      • Example: C:\Program Files\Java\jdk1.6.0\bin;
  • If there already IS a PATH variable, then double-click it, then place your cursor after the last semi-colon, and add the path of the Java \bin directory as shown above

Congratulations - you've successfully setup Java!

Previous: [[Java Tutorial/|]] Up: Java Tutorial Next: Choosing the right text editor

External links edit