To get started with Java development, we need to make our computer or PC ready with Java.
In this tutorial, we shall make Java Environment Setup for your Windows or Ubuntu Machine, to start Java programming.
Following are the steps to get your PC ready with Java programming language :
Install Java Developement Kit JDK
JDK contains everything that is required for writing a program, compiling it to byte code and running it on your machine. JDK is comprised of following components :
- Java Language – which specifies the syntax and core components.
- Tools and Tool APIs – these are the packages which make life easy in programming.
- JRE – The environment for running the java byte code.
Download latest JDK
Based on your operating system, Linux/Mac OS X/Solaris/Windows, and 32bit/64bit, download a jdk package from the below url[http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html] And follow the instructions of the installer.
Setup Java Path
For the Operating System to know about the location of java executor, Environment variables are to be setup.
Setup Java Path in Windows
Following is a step by step guide to setup Java Path in Windows computer
- Go to Advanced Environment Variables Window, Click on Windows button and navigate through the pathControl Panel -> System and Security -> System -> Advanced system settings -> Advanced -> Enviroment variables -> Advanced
- Edit “Path” environment variable, create new variable with name “Path” if already not existing
- Append the path of the java executable (path of java.exe in the Java installed folder) to the “Path” environment variable. For example, if path is
C:\WINDOWS\SYSTEM32, make it
C:\WINDOWS\SYSTEM32;C:\Program Files\Java\jdk1.7.0_40\binassuming the path of your java installation to be
Setup Java Path in Ubuntu
Following is a step by step guide to setup Java Path in Windows computer :
Step 1: Open a Terminal and run the following command to edit environment variables
$ sudo nano /etc/environment
Provide the password if prompted for.
Step 2: Add JAVA_HOME to the file. Append the following line to the end of the file
Replace the value with your Java Installation Path.
Step 3: Save the file and exit.
Note – Multiple JREs or JDKs
Multiple JREs and JDKs could be installed alongside one another and any of the installed could be used for compiling or executing a java program.
Verify the installation of Java
Let us check if Java has been installed correctly. Open command prompt in Windows or terminal in Ubuntu and run the following command
$ java -version
If Java is visible in the environment, javaw.exe responds to the command
java -version with the result shown in the following picture.
The result to
java -version, from the above picture notifies us the following:
- “1.8.0_111” is the version of JDK installed in the computer (running on OS : ubuntu 16.04)
- “1.8.0_111” is the version of JRE
- Java Virtual Machine is running in mixed mode. There are two basic modes namely Server mode and Client mode, in which Server mode is optimized for long running and Client mode is optimized for maximum performance. Running in mixed mode result in best of Client and Sever modes : long running and better performance.
In this Java Tutorial – Install Java, we have successfully installed Java and Setup Java Path in the environment variables. Now the computer’s environment is ready to handle java development. In our next Java Tutorial we shall see some of the Integrated Development Environments (IDE) for Java that are useful to make Java Programming Development easy, followed by our first program in Java, HelloWorld.java.