top

Search

Java Tutorial

How to install Java What are JDK and JRE? The Java Development Kit (JDK), officially called "Java Platform Standard Edition" or "Java SE" is required for writing Java programs. JDK is available free of charge from Sun Microsystems (now part of Oracle). The mother site of JDK (Java SE) is http://www.oracle.com/technetwork/java/javase/overview/index.html. JRE (Java Runtime) is required to run Java programs. To write and run Java programs, JDK (Java Development Kit), which includes JRE plus development tools (e.g. compiler and debugger) is needed. In other words, JRE is a subset of JDK. You should install JDK, which includes JRE, as you need both as a developer. Below are the steps to install Java Step 1: First uninstall the older version of JDK/JRE We recommend that only the latest JDK be installed. Although it is possible to install multiple versions of JDK / JRE simultaneously, it is messy. If you have an older version(s) of JDK/JRE in your system, uninstall ALL of them. Go to control panel and uninstall java. Step 2: Now download latest JDK Visit  https://www.oracle.com/java/technologies/javase-downloads.html Click on download button for JDK version you want to install. Ex. JDK 11. Click on the checkbox to "Accept License Agreement". Choose the JDK for your operating system, i.e., "Windows". Download the ".exe" installer. Execute the downloaded installer which will install both the JDK and JRE. In the "C:\Program Files\Java\jdk-11.0.{v }" directory, where {v} denotes the update number, JDK is installed by default. Accept the defaults and follow the JDK installation instructions on the screen. In this article, we will refer to the JDK installed directory as < JAVA HOME>. Step 3: Set path for JDK  Path and Classpath are variables of the environment at the operating system level. Path is used to define where the executables(.exe) files can be found by the system and classpath is used to specify the files.class location. In your java program, the path is set to use java tool such as java, javac, javap. Javac is used for code compilation. Open the System Properties. In the Properties Window, find the Advanced Tab. Click Environment Variables. Scroll down the variables of the system and find the variable PATH. Select the variable PATH and click Edit. Add the Java installation path to the PATH variable and save it. Step 4: Check if JDK installed correctly Go to Control Panel-->Program and Features and check if Java /JDK is listed there. Open command prompt and type java -version. If you get the version info, Java is installed correctly and PATH is also set correctly. Go to start menu-->System-->Advanced-->Environment Variables. Check if both PATH and JAVA_HOME are set correctly. How to Set the Environment Variable JAVA_HOME? Many Java applications (e.g. Tomcat) require setting the JAVA_HOME environment variable to the JDK directory. To set the JAVA_HOME environment variable please follow the below steps: Find out where Java is installed in the system. If you didn't change the path during installation, then the default path is like:ex. C:\Program Files\Java\jdk1.8.0_65In Windows 7 right-click My Computer and select Properties > Advanced.In Windows 8 go to Control Panel > System > Advanced System Settings.Click on the Environment Variables button.Under System Variables, click new.In the variable name field, enter:JAVA_HOME if you installed the JDK (Java Development Kit)or JRE_HOME if you installed the JRE (Java Runtime Environment)  In the Variable Value field, enter your JDK or JRE installation path and save it. Notes: Windows environment variables are NOT case-sensitive (such as JAVA HOME, PATH). 
logo

Java Tutorial

Environment Setup

How to install Java 

  • What are JDK and JRE? 

The Java Development Kit (JDK), officially called "Java Platform Standard Edition" or "Java SE" is required for writing Java programs. JDK is available free of charge from Sun Microsystems (now part of Oracle). The mother site of JDK (Java SE) is http://www.oracle.com/technetwork/java/javase/overview/index.html

JRE (Java Runtime) is required to run Java programs. To write and run Java programs, JDK (Java Development Kit), which includes JRE plus development tools (e.g. compiler and debugger) is needed. In other words, JRE is a subset of JDK. You should install JDK, which includes JRE, as you need both as a developer. 

  • Below are the steps to install Java 

Step 1: First uninstall the older version of JDK/JRE 

We recommend that only the latest JDK be installed. Although it is possible to install multiple versions of JDK / JRE simultaneously, it is messy. 

If you have an older version(s) of JDK/JRE in your system, uninstall ALL of them. Go to control panel and uninstall java. 

Step 2: Now download latest JDK 

  1. Visit  https://www.oracle.com/java/technologies/javase-downloads.html 
  2. Click on download button for JDK version you want to install. Ex. JDK 11. 
  3. Click on the checkbox to "Accept License Agreement". 
  4. Choose the JDK for your operating system, i.e., "Windows". Download the ".exe" installer. 

Execute the downloaded installer which will install both the JDK and JRE. 

In the "C:\Program Files\Java\jdk-11.0.{v }" directory, where {v} denotes the update number, JDK is installed by default. Accept the defaults and follow the JDK installation instructions on the screen. 

Java

In this article, we will refer to the JDK installed directory as < JAVA HOME>. 

Step 3: Set path for JDK  

Path and Classpath are variables of the environment at the operating system level. Path is used to define where the executables(.exe) files can be found by the system and classpath is used to specify the files.class location. In your java program, the path is set to use java tool such as java, javac, javap. Javac is used for code compilation. 

  1. Open the System Properties. 
  2. In the Properties Window, find the Advanced Tab. Click Environment Variables. 
  3. Scroll down the variables of the system and find the variable PATH. Select the variable PATH and click Edit. 
  4. Add the Java installation path to the PATH variable and save it. 

Step 4: Check if JDK installed correctly 

  1. Go to Control Panel-->Program and Features and check if Java /JDK is listed there. 
  2. Open command prompt and type java -version. If you get the version info, Java is installed correctly and PATH is also set correctly. 
  3. Go to start menu-->System-->Advanced-->Environment Variables. Check if both PATH and JAVA_HOME are set correctly. 
  • How to Set the Environment Variable JAVA_HOME? 

Many Java applications (e.g. Tomcat) require setting the JAVA_HOME environment variable to the JDK directory. 

To set the JAVA_HOME environment variable please follow the below steps: 

  • Find out where Java is installed in the system. If you didn't change the path during installation, then the default path is like:ex. C:\Program Files\Java\jdk1.8.0_65
  • In Windows 7 right-click My Computer and select Properties > Advanced.In Windows 8 go to Control Panel > System > Advanced System Settings.
  • Click on the Environment Variables button.
  • Under System Variables, click new.
  • In the variable name field, enter:
    • JAVA_HOME if you installed the JDK (Java Development Kit)or 
    • JRE_HOME if you installed the JRE (Java Runtime Environment)  
  • In the Variable Value field, enter your JDK or JRE installation path and save it. 

Notes: Windows environment variables are NOT case-sensitive (such as JAVA HOME, PATH). 

Leave a Reply

Your email address will not be published. Required fields are marked *