In order to run Java application you need to have first installed Java on your Mac or Windows
laptop or desktop.
It’s absolutely required to complete Java setup right way for your production & development applications. If you are a first time Java user then first step is to go to official Oracle website
and download JDK.
Below detailed steps will help also if you have below questions:
- How to fix JAVA_HOME error while starting Tomcat Server?
- Why i’m getting jre_home is not defined correctly tomcat error?
- How to set jre_home environment variable?
- jre_home on windows
- Difference between java_home vs jre_home
- How to set jre_home via command line?
In this tutorial we will discuss how to install Java, setup JRE_HOME & JAVA_HOME environment variables on Windows platform only. For Mac and Linux, I’ll publish another tutorial with all detailed steps later.
Let’s get started
Step-1
Configure JAVA_HOME / JRE_HOME Environment Variables
- Go to
official Oracle site
and Download JDK binary - Click on
Java Download
- Accept
License Agreement
Download
binary next toWindows x64
Step-2
- Double click on
.exe
file and it will install JDK and JRE both on your Windows Laptop/Desktop - By default it will install JDK and JRE at location:
C:\Program Files\Java
folder
Step-3
- Now minimize all windows and you will see Desktop icon (check this screenshot)
Right click
on it- Click on
Properties
- Click on
Advanced System Settings
link as you in above diagram
Step-4
- Click on
Advanced
Tab - Click on
Environment Variables...
button
Step-5
- New Pop-up Window will appear
- Click on New…
- Enter
JAVA_HOME
as variable name andC:\Program Files\Java\jdk1.8.0_121
as Value - Enter
JRE_HOME
as variable name andC:\Program Files\Java\jre1.8.0_121
as Value - Click
OK
button - Exit System Properties window
At this time, you are all set.
How to verify?
How to verify if JAVA_HOME and JRE_HOME environment variables setup correctly or not?
- Just open command prompt
- Type
java -version
- It will print installed Java details as shown below
That’s it. Let me know if you face any issue installing Java on your laptop. Make sure to update Java version number as per your installation in above steps. Happy coding and happy open sourcing.
What is a difference Between JRE and JDK?
Ideally JRE provides runtime environment
for your application. While running your development or production environment, you just need JRE.
On other end, while you are developing Java application
, JDK provides more debugging and development functionalities which wont part of JRE.