Installation
Navigate Getting Started topic:
)
|
- For in-depth information, see the chapter on the Java platform.
In order to make use of the content in this book, you would need to follow along each and every tutorial rather than simply reading through the book. But to do so, you would need access to a computer with the Java platform installed on it – the Java platform is the basic prerequisite for running and developing Java code, thus it is divided into two essential software:
- the Java Runtime Environment (JRE), which is needed to run Java applications and applets; and,
- the Java Development Kit (JDK), which is needed to develop those Java applications and applets.
However as a developer, you would only require the JDK which comes equipped with a JRE as well. Given below are installation instruction for the JDK for various operating systems:
[edit] For Windows
[edit] Download instructions
Some Windows based systems come built-in with the JRE, however for the purposes of writing Java code by following the tutorials in this book, you would require the JDK nevertheless. To acquire the latest JDK (version 7), you can manually download the Java software from the Oracle website.
For the convenience of our readers, the following table presents direct links to the latest JDK for the Windows operating system.
Operating system | Setup Installer | License |
Windows x86 | Download | Oracle Binary Code License Agreement |
Windows x64 | Download | Oracle Binary Code License Agreement |
You must follow the instructions for the setup installer wizard step-by-step with the default settings to ensure that Java is properly installed on your system. Once the setup is completed, it is highly recommended to restart your Windows operating system.
If you kept the default settings for the setup installer wizard, you JDK should now be installed at C:\Program Files\Java\jdk1.7.0_01. You would require the location to your bin folder at a later time – this is located at C:\Program Files\Java\jdk1.7.0_01\bin It may be a hidden file, but no matter. Just don't use Program Files (x86)\ by mistake unless that's were installed Java.
[edit] Updating environment variables
In order for you to start using the JDK compiler utility with the Command Prompt, you would need to set the environment variables that points to the bin folder of your recently installed JDK. Follow the steps below to permanently include your Java platform to your environment variables.
1. | For Windows XP, click Start › Control Panel › System. |
For Windows 2000, click Start › Settings › Control Panel › System. | |
For Window Vista or Windows 7, click Start › Control Panel › System and Maintenance › System. | |
Alternatively, you can also press ⊞ Win+R to open the Run dialog. With the dialog open, type the following command at the prompt:
rundll32 shell32.dll,Control_RunDLL sysdm.cpl |
|
2. | Navigate to the Advanced tab on the top, and select Environment Variables... |
3. | Under System variables, select the variable named Path and click Edit... |
4. | In the Edit System Variable dialog, go the the Variable value field. This field is a list of directory paths separated by semi-colons (;). |
5. | To add a new path, append the location of your JDK bin folder separated by a semi-colon (;). |
6. | Click OK on every opened dialog to save changes and get past to where you started. |
[edit] Start writing code
Once you have successfully installed the JDK on your system, you are ready to program code in the Java programming language. However, to write code, you would need a decent text editor. Windows comes with a default text editor by default – Notepad. In order to use notepad to write code in Java, you need to follow the steps below:
1. | Click Start › All Programs › Accessories › Notepad to invoke the application. |
Alternatively, you can also press ⊞ Win+R to open the Run dialog. With the dialog open, type the following command at the prompt:
notepad |
|
2. | Once the Notepad application has fired up, you can use the editor to write code for the Java programming language. |
The problem with Notepad however is that it does not support developer-friendly features, such as syntax highlighting and code completion. These features are a vital part of the exercise of writing code. Nevertheless, there are a variety of different open-source editors available as alternatives to Notepad that support these features.
For the purposes of the tutorials in this book, the most recommended editor is the Notepad++, a free and open-source fully integrated text editor that supports syntax highlighting and code completion. You need to download the latest version of Notepad++ in order to start writing code with the editor.
[edit] For Linux
[edit] Installation using Terminal
Downloading and installing the Java platform on Linux machines (in particular Ubuntu Linux) is very easy and straight-forward. To use the terminal to download and install the Java platform, follow the instructions below.
1. | For Ubuntu, go to Application › Accessories › Terminal. |
Alternatively, you can press Alt+F2 to open the Run Application window. At the prompt, type xterm or gnome-terminal to open the Terminal window. |
|
2. | At the prompt, write the following:
$ sudo apt-get install openjdk-7-jdk openjdk-7-jre openjdk-7-doc |
3. | All Java software should be installed and instantly available now. |
[edit] Download instructions
Alternatively, you can manually download the Java software from the Oracle website.
For the convenience of our readers, the following table presents direct links to the latest JDK for the Linux operating system.
Operating system | RPM | Tarball | License |
Linux x86 | Download | Download | Oracle Binary Code License Agreement |
Linux x64 | Download | Download | Oracle Binary Code License Agreement |
[edit] Start writing code
The most widely available text editor on Gnome desktops is the Gedit application, while on the KDE desktops, one can find Kate. However unlike Notepad on Windows, both these editors support syntax highlighting and code completion and therefore are sufficient for our purposes.
However, if you require a robust and standalone text-editor like the Notepad++ editor on Windows, you would require the use of the minimalistic editor loaded with features – SciTE. Follow the instructions below if you wish to install SciTE:
1. | For Ubuntu, go to Application › Accessories › Terminal. |
Alternatively, you can press Alt+F2 to open the Run Application window. At the prompt, type xterm or gnome-terminal to open the Terminal window. |
|
2. | At the prompt, write the following:
$ sudo apt-get install scite |
3. | You should now be able to use the Scite editor for your programming needs. |
[edit] For Mac OS
[edit] For Online
If you already have the JRE installed, you can use the Java Wiki Integrated Development Environment (JavaWIDE) to code directly in your browser, no account or special software required.
Click here to visit the JavaWIDE Sandbox to get started.
For more information, click here to visit the JavaWIDE site.