Prerequisite : You have installed Java Runtime Environment (any version jre6, jre7, or jre8)
Let's see how you can set the JAVA_HOME Environment variable for Windows Operating systems,Step 1. Find out where JRE has been installed
Once you install JRE you need to locate where java has been installed on your system. And the folder that you need to look for is Program Files
Note: If you have a 64-bit Windows Operating system installed then you will have 2 program files folders under C:/
- Program Files
- Program Files(x86)
If you find the Java folder under "Program Files(x86)" then the installed java version is 32-bit if you find it under "C:/Program Files/Java" means the Java version is 64-bit.
Look that you can see jre6 folder under java directory, i.e. : C:/Program Files/Java/jre6 or C:/Program Files(86)/Java/jre6
Step 2. Setting-up JAVA_HOME
- Right Click on My Computer icon and select Properties option and Select Advance tab.
- Now look for the Environment Variable button and Click on it.
- Now look for System Variables and click on New,
- Add Variable name => JAVA_HOME and Variable value => C:/Program Files/Java/jre7 or C:/Program Files(86)/Java/jre7
- Click OK and Apply Changes.
For Windows 7/Window 10/Windows 11
- Go to Start menu and select Computer
- Select System Properties from the context menu
- Now click on Advanced System Settings and go to Advanced tab
- Now click on Environment Variables
- Under System Variables look for PATH.
- Modify PATH by adding the location of the class to the value for PATH.
- Reopen Command prompt window, and run your java code, if the code works, the path is been set correctly.
Setting JAVA_HOME using Eclipse
You can set the Java environment variable in eclipse by going to,
Eclipse -> Window -> Preferences -> Java -> Installed JREs
Now here you can search for the location where the JRE is been installed and select it.
- Add two numbers using Java Generics
- Convert Java List to Json String using Jackson
- Convert Java Object to JSON using Jackson Library
- Java SE JDBC: Insert with PreparedStatement Example
- [Program] How to read three different values using Scanner in Java
- Java JDBC Batch Update Example with PreparedStatement
- Java Stream flatmap() Examples
- Save Java Object as JSON file using Jackson Library
- Java get day of the week as an int using DayOfWeek
- Create Nested Directories using Java Code
- Java JDBC Delete a Record in Database Table using PreparedStatement
- List of jars required for Struts2 project
- Convert Java Object to XML using Jackson Library
- Struts2 : java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
- Java JDBC Get Id of the Inserted Record with AutoIncrement
- How to list all tables using Java JDBC
- Java Jackson ObjectMapper Class with Examples
- Fix: Maven - Failed to execute goal - Compilation failure - Source/Target option 5 is no longer supported. Use 7 or later
- Eclipse : The type java.lang.CharSequence cannot be resolved. Indirectly referenced from required .class files
- Formatting Double in Java [Examples]
- How to run Java Unit Test cases with Apache Maven?
- [fix] NullPointerException Cannot Invoke findById because Repository is null - Java Spring
- [Fix] java: integer number too large compilation error
- [Java] Read a File with UTF-8 Encoding
- How to detect Operating System using Java code
- Android : IOException: Unable to open sync connection! - Android
- Force convert HTML text input to upper case - Html
- How to Disable Mac Terminal Bell Sound - MacOS
- Android Emulator Screenshot saved location - Android-Studio
- How to Adjust macOS System Font Size - MacOS
- Cmd command get current directory location - Windows
- CentOS Cannot find a valid baseurl for repo base7x86_64 yum - HowTos
- How to enable line numbers in Eclipse IDE - Eclipse