Java Environment Setup
Before starting programming in Java, you need to setup your environment (computer system) to be able to provide you with the interface through which you can start programming. In this section, you will understand the requirements for setting up your environment.
The following step by step guide will help you setting up Java on your local machine.
- Java SE is an open-source programming suite and is freely available from Java official website. You can download the most recent and most up to date version from “http://www.oracle.com/technetwork/java/javase/downloads/” link. You need to select the compatible version with your operating system.
- After download the Java Setup, execute the .exe file. A setup wizard will guide you throughout the process.
- Once Java is installed on your machine, you will need to set the environment variables to point to the correct installation directories. This is extremely important as without setting up the environment variable, you will not be able to run Java.
Setting up the Environment Variable in Windows OS
The default path for Java installation is c:\Program Files\java\jdk directory however, it may vary. So you will need to note down the installation path during the installation process. In this tutorial, it is assumed that the default path has been used. Now, follow the steps below to set the environment variable.
- Get System properties by Right-clicking on the ‘My Computer’ icon and selecting ‘Properties’.
- Select Advance Tab in System Properties windows
- Under the advance tab, click ‘Environment variables’ button as shown in Figure 1
Figure 1 System Properties Window
- Now, edit the “Path” variable (as shown in Figure 3) so that it also contains the path to the Java executable. Example, if the path is currently set to ‘C:\WINDOWS\SYSTEM32’. Go to the end of the path string. Insert “;” symbol as a delimiter and add the path to Java files. Your new Path variable will look something like ‘C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin’. As shown in Figure 2
Figure 2 Edit Environment Variable
Figure 3 Environment Variables
Setting up Path in UNIX, Linux, Solaris and FreeBSD Operating Sytems
Similar to Windows Operating System, In UNIX and Linux OS etc., environment variable “PATH” also needs to be set to point to the location where Java binaries are installed. In this regard, you need to refer to your shell documentation (bash, csh etc.) if you face any trouble doing so.
For Example, in bash shell, you will need to add the following line at the end of your “.bash”
rc: export PATH=/path/to/java:$PATH
Popular Java Editors
All the above talk, is just to setup your environment to support Java, however, to start programming in Java, you will need an IDEs editor program that allows you to write Java’s code and execute it.
There are a great number of sophisticated IDEs available on the internet but you are highly recommended to use the following.
Notepad: If you do not want to use any proprietary IDE, you can use Windows built-in simple text editor called Notepad (Recommended for this tutorial), Word Pad.
Netbeans: Netbeans is an open-source Java IDE that is free and can be downloaded from www.netbeans.org/index.html.
Eclipse: Eclipse is another open-source Java IDE developed by the eclipse community. It is downloadable from www.eclipse.org.