- Administering Data Integration for Oracle Enterprise Performance Management Cloud
- EPM Integration Agent
- Installing and Configuring the EPM Integration Agent
The JAVA_HOME environment variable points to the directory where the Java runtime environment (JRE) is installed on your computer.
The following tasks provide the information you need to set JAVA_HOME on Windows or UNIX systems.
To set JAVA_HOME on a Windows system:
Right click My Computer and select Properties .
On the Advanced tab, select Environment Variables , and then edit JAVA_HOME to point to the location of the of the Java Runtime Environment (JRE).
For example, you might specify: C:\Program Files\Java\jdk1.8\jre
JRE is part of the Java Development Kit (JDK) but can be downloaded separately.
To set JAVA_HOME on a UNIX system:
For Korn and bash shells, specify:
For a Bourne shell, specify:
For a C shell, specify:
- No suggested jump to results
Here are 4 public repositories matching this topic..., mytask1234 / ebay-game-manager.
Game Manager with Resolver – Home Assignment
- Updated Aug 2, 2020
ZhekehZ / SD-NBash
SoftwareDesign home assignment
- Updated Jun 7, 2020
mytask1234 / ubimo-home-task
Ubimo Home Task
- Updated Sep 6, 2020
mytask1234 / vmware-2nd-interview-DAG
VMware 2nd Interview - Create a class which represents a DAG (directed acyclic graph)
- Updated Sep 8, 2020
Improve this page
Add a description, image, and links to the home-assignment topic page so that developers can more easily learn about it.
Curate this topic
Add this topic to your repo
To associate your repository with the home-assignment topic, visit your repo's landing page and select "manage topics."
- EXPLORE Coupons Tech Help Pro Random Article About Us Quizzes Contribute Train Your Brain Game Improve Your English Popular Categories Arts and Entertainment Artwork Books Movies Computers and Electronics Computers Phone Skills Technology Hacks Health Men's Health Mental Health Women's Health Relationships Dating Love Relationship Issues Hobbies and Crafts Crafts Drawing Games Education & Communication Communication Skills Personal Development Studying Personal Care and Style Fashion Hair Care Personal Hygiene Youth Personal Care School Stuff Dating All Categories Arts and Entertainment Finance and Business Home and Garden Relationship Quizzes Cars & Other Vehicles Food and Entertaining Personal Care and Style Sports and Fitness Computers and Electronics Health Pets and Animals Travel Education & Communication Hobbies and Crafts Philosophy and Religion Work World Family Life Holidays and Traditions Relationships Youth
- HELP US Support wikiHow Community Dashboard Write an Article Request a New Article More Ideas...
- EDIT Edit this Article
- PRO Courses New Guides Tech Help Pro New Expert Videos About wikiHow Pro Coupons Quizzes Upgrade Sign In
- Premium wikiHow Guides
- Browse Articles
- Quizzes New
- Train Your Brain New
- Improve Your English New
- Support wikiHow
- About wikiHow
- Easy Ways to Help
- Approve Questions
- Fix Spelling
- More Things to Try...
- H&M Coupons
- Hotwire Promo Codes
- StubHub Discount Codes
- Ashley Furniture Coupons
- Blue Nile Promo Codes
- NordVPN Coupons
- Samsung Promo Codes
- Chewy Promo Codes
- Ulta Coupons
- Vistaprint Promo Codes
- Shutterfly Promo Codes
- DoorDash Promo Codes
- Office Depot Coupons
- adidas Promo Codes
- Home Depot Coupons
- DSW Coupons
- Bed Bath and Beyond Coupons
- Lowe's Coupons
- Surfshark Coupons
- Nordstrom Coupons
- Walmart Promo Codes
- Dick's Sporting Goods Coupons
- Fanatics Coupons
- Edible Arrangements Coupons
- eBay Coupons
- Log in / Sign up
- Computers and Electronics
How to Set JAVA_HOME for JDK & JRE: A Step-by-Step Guide
Last Updated: January 30, 2023
This article was co-authored by wikiHow staff writer, Nicole Levine, MFA . Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. This article has been viewed 299,423 times. Learn more...
Are you seeing Java errors like "JAVA_HOME is not defined correctly?" or "JAVA_HOME is set to an invalid directory?" If you've recently installed the Java Development Kit ( JDK ) or the Java Runtime Environment (JRE), you'll need to set your JAVA_HOME variables and configure the path so applications know where to find Java. This wikiHow article will show you the easiest ways to change or set the Java home path on Windows, macOS, and Linux.
Things You Should Know
- Before you can set JAVA_HOME, you'll need the full path to your JDK or JRE installation.
- Once you set the JAVA_HOME environment variable, you can run the command echo $JAVA_HOME to see the new path.
- To set the Java home and path on Linux or macOS permanently (even after a reboot), add the environment variables to your .bashrc or .zshrc file.
- Open File Explorer, click This PC in the left panel, then navigate to C:\Program Files\Java. The directory you're looking for should have the name of the JDK version, such as C:\Program Files\Java\jdk-19.
- If you installed the JRE instead of the JDK, you'll have something like C:\Program Files\Java\jre1.8.0_351 instead.
- You can also open the command prompt and run the command wmic product where "Name like '%%Java%%'" get installlocation,Name . This will tell you the full path of the JDK, even if you haven't yet set JAVA_HOME.
- Press the Windows key on your keyboard and type advanced system .
- Click View advanced system settings in the search results.
- If you have multiple installations of the JDK and want to change JAVA_HOME to your new installation, select the current JAVA_HOME user variable and click Edit… instead.
- If you're editing the current JAVA_HOME path, you'll already have JAVA_HOME here. So, you can skip this step.
- If you're adding a second path to JAVA_HOME, just type a semicolon (;) after the first path, then enter the second path.
- If you're replacing an old JAVA_HOME path, just delete the current path and enter the new one.
- If you want other users on this PC to be able to access Java binaries from the command line, repeat this step for the "Path" variable under "System variables" as well.
- Click the New button at the top.
- Enter the full path to the JRE or JDK with \bin at the end. For example, C:\Program Files\Java\jdk-19\bin or C:\Program Files\Java\jre1.8.0_351\bin.
- You won't need to restart your computer for the changes to take effect, but you will need to relaunch any apps that were trying to access Java.
- Make sure this is a new command prompt window. If you still have the same window open, the command will fail because it doesn't have the new environment variables.
- If you have more than one Java installation and want to see the paths to all of them, use /usr/libexec/java_home -V instead.
- Type cd ~ and press Return .
- Type open .zshrc and press Return . This should open the file in a text editor.
- If the file is not found, type echo > .zshrc and press Return . Then, run open .zshrc again.
- Replace /Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home with the full path to the /Contents/Home directory of your Java installation if it's different.
- export PATH=$JAVA_HOME/bin:$PATH
- Save the file and exit the text editor when you're finished.
- If you had any other windows open that were attempting to find Java binaries, close and reopen them.
- Shopping for PC accessories or office supplies? Check out our coupon site for Staples discounts or our coupon site for Office Depot.
- This method will work in just about any version of Linux, including Ubuntu and Redhat.
- readlink -f `which javac`
- If that doesn't work, try running update-alternatives --list java .
- Once you get the directory, find out where it links using ls -la /bin/java .
- If that points you to another directory, e.g., /etc/alternatives/java, run ls -la /etc/alternatives/java .
- At that point, you should see a much longer directory, which is actually the home to the Java binaries. For example, usr/lib/jvm/java-11-openjdk-arm64/bin/java . This is the directory you want.
- echo "export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64" >> ~/.bashrc
- echo "export PATH=$PATH:$JAVA_HOME/bin" >> ~/.bashrc
- At this point, you can run echo $JAVA_HOME to see the location of Java on your system.
Video . by using this service, some information may be shared with youtube..
- In Linux, you can set JAVA__HOME for all users by editing the global .bashrc, which is located at /etc/bash.bashrc. Just use echo and replace ~/.bashrc with /etc/bash.bashrc . ⧼thumbs_response⧽ Helpful 0 Not Helpful 0
- On both Linux and macOS, you can set the Java home in your .bash_profile or .zprofile if you prefer. ⧼thumbs_response⧽ Helpful 0 Not Helpful 0
You Might Also Like
- ↑ https://docs.oracle.com/en/cloud/saas/enterprise-performance-management-common/diepm/epm_set_java_home_104x6dd63633_106x6dd6441c.html
- ↑ https://support.apple.com/guide/terminal/change-the-default-shell-trml113/mac
- ↑ https://docs.oracle.com/cd/E19182-01/821-0917/inst_jdk_javahome_t/index.html
About This Article
- Send fan mail to authors
Is this article up to date?
- Do Not Sell or Share My Info
- Not Selling Info
wikiHow Tech Help Pro:
Level up your tech skills and stay ahead of the curve
- JSRs and APIs
Grafvision - Fotolia
How to set JAVA_HOME in Windows and echo the result
Set java_home properly and echo your results with the following tidbits, and also examine how a proper path installation can benefit your local environment..
- Cameron McKenzie, TechTarget
If you plan to run software programs like Maven, Jenkins, Gradle or Tomcat, you'll not only need a local installation of the JDK, but you'll also want to ensure that you have set JAVA_HOME correctly. Here is how you can accomplish that task with a demonstration of how to set JAVA_HOME in Windows and echo the result to validate that the changes have gone into effect. Also, let's explore how you can add Java to the Windows PATH, which is another configuration parameter that is often set after a JDK installation .
How to set JAVA_HOME in Windows
Three ways to set the JDK JAVA_HOME variable in Windows include:
- allow the Java installer to do it;
- use the environment variable editor; and
- use the command line.
OpenJDK's JAVA_HOME configuration tool
Not every Java installer will automatically set JAVA_HOME for you. The AdoptOpenJDK one will, and it can configure the PATH variable for you as well. But, it doesn't do it all by default. You must perform a custom install and select one of the following two options to have the OpenJDK installer set JAVA_HOME and PATH environment variables :
- add to PATH; or
- set JAVA_HOME variable.
That's all there is to it. Once the OpenJDK installation is complete, the JAVA_HOME variable will be configured and the bin directory of the JDK will be added to the Windows PATH. It doesn't get much easier than that.
The JAVA_HOME environment variable editor
If your JDK installation didn't set JAVA_HOME automatically, you can always open the Windows environment variable editor and set it yourself. This is the easiest way to manually set JAVA_HOME in Windows 7, 8 and 10 .
Follow these steps to manually set JAVA_HOME:
- Open the Windows System Properties Control Panel applet on any version of Windows.
- Choose Advanced System settings.
- Click on the Environment Variables button.
- Click on the New button under System Variables.
- Set JAVA_HOME as the environment variable name.
- Set the location of the JDK installation as the environment variable Value.
- Click OK and close the JAVA_HOME environment variable editor.
After you add the new environment variable, close any and all DOS prompts and command windows, because these tools load environment variables only when they first start. If you try to access the JAVA_HOME variable in any windows that were open prior to the change, the variable will come back as null or undefined. But if you open a new command window, scripts that search for JAVA_HOME will run successfully.
The setx JAVA_HOME command
The third way to configure the Windows JAVA_HOME environment variable is to use the command line and invoke the setx command as follows:
@REM Configure JAVA_HOME in Windows 10 with setx setx JAVA_HOME -m "C:\_jdk12.0" >> setx JAVA_HOME command completed successfully
As you can see, the setx JAVA_HOME approach is relatively simple. Still, command line interface tools can intimidate some people, and this type of manual coding is prone to error. However, when you write scripts to automate the configuration of the environment, the ability to script the process with setx becomes invaluable.
How to echo JAVA_HOME in Windows
After you set JAVA_HOME in Windows, it's a good idea to verify that the change has persisted. The easiest way to do this is to echo JAVA_HOME in a command prompt or a BASH shell.
To echo JAVA_HOME in a Windows DOS prompt or command window, you simply bookend the variable with percentage signs:
@REM How to echo JAVA_HOME in windows echo %JAVA_HOME% >> C:\_jdk12.0
If you use a BASH shell, or if you have set JAVA_HOME in an Ubuntu environment and need to echo JAVA_HOME in Linux, place a single dollar sign before the environment variable: echo $JAVA_HOME .
How to get JAVA_HOME in Windows scripts
The manner in which you get JAVA_HOME within batch files and shell scripts follows the exact same syntax used by the echo command. Bookend the variable with percentage signs and use that variable within your code just as you would any other scripted variable.
Scripts that use JAVA_HOME should always be checked to see if the variable exists. If it does not, an appropriate error message will arise. Here is how the Apache Maven project gets JAVA_HOME in its startup script and reports any errors during the process:
@REM Apache Maven JAVA_HOME Startup Script @REM ==START JAVA_HOME VALIDATION == if not "%JAVA_HOME%"=="" goto OkJHome for %%i in (java.exe) do set "JAVACMD=%%~$PATH:i" goto checkJCmd
:OkJHome set "JAVACMD=%JAVA_HOME%\bin\java.exe"
:checkJCmd if exist "%JAVACMD%" goto chkMHome
echo JAVA_HOME environment variable is not defined correctly >&2 echo This environment variable is needed to run this program >&2 echo NB: JAVA_HOME should point to a JDK not a JRE >&2 goto error
The JAVA_HOME PATH setting in Windows
The JAVA_HOME and PATH environment variables serve two very different purposes. JAVA_HOME simply points to where Java is installed. If you add something to the PATH variable, it makes it available throughout the entire operating system. Of course, many developers who install Java actually want the runtime universally available, so they set the JAVA_HOME and PATH environment variables at the same time.
The big distinction between PATH and JAVA_HOME settings is that the former points to the JDK bin directory, while the latter points to the installation directory. Developers are notorious for mixing up these two settings, which invariably leads to program start issues and the subsequent JAVA_HOME error messages such as "java_home is set to an invalid directory" or "java_home environment variable is not set."
The JAVA_HOME bin combination
When you add the JDK \bin directory to the PATH, you can specify the absolute path, or you can get clever and reference the JAVA_HOME environment variable as so:
How to set JRE_HOME in Windows
It is worth noting that while a JDK installation is linked to the JAVA_HOME environment variable, JRE installations are typically linked to the JRE_HOME variable. The steps to set up JRE_HOME on a Windows machine are exactly the same as those outlined above, with the exception that the JRE_HOME variable will point to the root of the JRE installation, while the JAVA_HOME environment variable in Windows points to the root of the JDK installation.
Dig Deeper on JSRs and APIs
How do I install Java?
How do I install Java on Ubuntu?
How do I install Java on Windows?
Full GitHub Actions environment variables list for YAML build workflow scripts example
Open banking has made financial transactions easier and more secure for those with multiple banking accounts; however, ...
REST may be a somewhat non-negotiable standard in web API development, but has it fostered overreliance? Learn why other design ...
Developers can use Microsoft Azure Logic Apps to build, deploy and connect scalable cloud-based workflows. Learn how it measures ...
A new CLI extension and other features due to ship this month lay the groundwork to help developers make better use of software ...
GitHub has added SMS support and fresh account lockout prevention features to its phased rollout plans as it prepares to ...
The new API is faster and cheaper than the previous ChatGPT interface, and users can opt out of submitting their data to it, ...
AWS Compute Optimizer and Cost Explorer monitor, analyze and optimize your cloud costs. Compare the two tools to choose which is ...
Azure management groups, subscriptions, resource groups and resources are not mutually exclusive. Businesses can -- and often do ...
Amazon CodeGuru reviews code and suggests improvements to users looking to make their code more efficient as well as optimize ...
While DC Health Link confirmed the breach, it is unknown how threat actors obtained the personal health data of more than 56,000 ...
Wireshark display filters enable users to narrow the scope of a network traffic scan. Use this tutorial to apply and edit display...
Wireshark has a variety of uses, which is why creating multiple personalized Wireshark profiles is important. Learn about ...
Many organizations struggle to manage their vast collection of AWS accounts, but Control Tower can help. The service automates ...
There are several important variables within the Amazon EKS pricing model. Dig into the numbers to ensure you deploy the service ...
AWS users face a choice when deploying Kubernetes: run it themselves on EC2 or let Amazon do the heavy lifting with EKS. See ...
Scaling developer productivity
- Search for:
JAVA_HOME vs. PATH Environment Variables
Last Updated on November 25, 2022
To compile and run Java applications successfully you’ll need to setup the JAVA_HOME and PATH environment variables. In this article you’ll learn what these variables do, when to use each of them, and how to set them up properly on your Windows system.
What is PATH used for?
The PATH environment variable consists of a list of directories containing executable programs on your system. In Windows, these programs are files which end in .exe . By including a program’s directory in PATH it becomes available to use on the command line by name, without having to specify its full path.
So for easy access to a program, add the directory that contains it to the PATH . Let’s see how that works so we can run programs contained within the Java Development Kit (JDK).
Here’s a snippet of my PATH environment variable.
It includes an entry for C:\Java\jdk-17.0.2\bin , my JDK installation. In fact, it points to the bin directory containing Java programs such as:
- java (for running Java)
- javac (for compiling Java)
- jar (for packaging Java jar archives)
What effect does having this on the PATH have?
It means I can run any Java command contained in the bin directory from the Windows Command Prompt , simply by specifying the command name.
Yes, even though I’m in my user home directory, I can use the java program as though it were in this directory by just running java --version .
And that’s all thanks to the PATH environment variable.
What happens when Java is not on PATH?
If I remove Java from PATH something catastrophic happens. 💥
OK, maybe not that bad, but we do get an error when trying to run java .
That’s because Windows doesn’t know where to find the java command.
If we want, we can instead run java using its full path. In my case that’s:
A bit of a mouthfull right? Much better to setup PATH instead.
OK…so we nailed PATH . Why on earth do we need JAVA_HOME as well then?
What is JAVA_HOME used for?
The JAVA_HOME environment variable is set to the JDK installation directory. The variable can then be used by any program that needs access to the JDK.
You can think of JAVA_HOME as a pointer. Any time you start a program that relies on the JDK in some way, the program uses that pointer to find it.
I’ll set JAVA_HOME to C:\Java\jdk-17.0.2 and then we’ll try running a program that uses it.
The popular build automation tool Gradle uses JAVA_HOME to locate the JDK. When we run gradle --version , we see in the output that it’s found the version of Java we set in JAVA_HOME .
Many other programs use JAVA_HOME in a similar way e.g. Maven, Eclipse.
What happens when JAVA_HOME is not set?
If JAVA_HOME isn’t set then programs that rely on it might not be able to locate the JDK. In the worst case scenario this will stop the program from executing. 🤚
When we run the same Gradle command, we get an error JAVA_HOME is not set .
Do we need to set both JAVA_HOME and PATH?
Some modern programs are intelligent enough to extract the JDK location from PATH if JAVA_HOME is not set. For example, with Gradle you can set either PATH or JAVA_HOME and it will run fine.
Other programs, such as the Eclipse IDE, need at least the PATH in order to startup.
For the best compatibility with new and old programs that use Java always set both JAVA_HOME and PATH .
If you’re concerned about maintaining two environment variables, you can actually reference one from the other, as you’re about to see.
How to set JAVA_HOME and PATH in Windows
Hopefully by now you’re convinced to set JAVA_HOME and PATH to compile and run Java on your system.
But how do you actually set them up in Windows?
First you need to locate your JDK installation. If you haven’t installed the JDK yet, download it from jdk.java.net and extract it into your directory of choice.
In Windows explorer, locate the JDK installation directory and copy the location from the address bar.
Now press Start , type Environment , and select Edit the system environment variables .
On the dialog that appears, select Environment Variables at the bottom.
The Environment Variables dialog appears, which is the main place from which we control environment variables in Windows. Yeah, like mission control but without the colourful buttons.
We’ll first create JAVA_HOME . Select New under System variables to create a system variable which will be available to any user on your system.
In the dialog that appears, set a Variable name of JAVA_HOME and for Variable value paste the JDK directory location you copied earlier.
That’s JAVA_HOME added. Awesome!
Adding Java to PATH
Back on the Environment Variables dialog we’re going to edit the system variable called Path .
Yeah I know, I’ve been calling it PATH instead of Path up to this point. But actually Windows environment variables aren’t case sensitive, so no worries!
Double click Path and it will bring up a list of all the directories contained in the variable. We need to add a new entry so hit New .
You’ll end up in a text box where you should enter the value %JAVA_HOME%\bin . This references the JAVA_HOME variable so we don’t repeat the same information twice.
Hit OK , then on the Environment Variables dialog hit OK again to save your changes.
JAVA_HOME vs. PATH values: notice how the directory we set for JAVA_HOME is the JDK installation root whereas for PATH we add the bin directory within the JDK installation. Take care to set these up correctly otherwise you’ll have problems later on.
How to check that JAVA_HOME and PATH are setup correctly
Now that you’ve setup the two Java-related environment variables, start a new Windows Command Prompt to test them out.
- to validate PATH run java --version . You should see Java version information printed on your screen.
- to validate JAVA_HOME run echo %JAVA_HOME% . You should see the location of your JDK installation.
Now you can try running your favourite Java program and everything should work perfectly.
You now understand the difference between the JAVA_HOME and PATH environment variables, how they’re used, and how to set them up so you can compile and run Java programs on your system.
Remember that you’ve setup PATH to reference JAVA_HOME , so whenever you need to update Java you only need to change one value.
Now you’ve crossed this off the list it’s time to start building some Java applications. The fastest and most powerful Java build tool available right now is Gradle. Check out the free course and tutorials I made just for you below. 👇
Want to learn more about Gradle? Check out the full selection of Gradle tutorials .
4 thoughts on “ JAVA_HOME vs. PATH Environment Variables ”
what happens if there are two commands with same name in different paths,which one will run.
Hi Manideep. The first entry will be chosen.
Hello, thanks for the information
What is the need to refer to java from the path, wouldn’t it be better to have the variables separately?
Hi Juan. If the Java bin directory isn’t in the PATH , you can’t run the java command from the command line.
Leave a Reply Cancel reply
Your email address will not be published. Required fields are marked *
Save my name, email, and website in this browser for the next time I comment.
Set the JAVA_HOME Variable · Locate your Java installation directory · Do one of the following: · Click the Environment Variables button. · Under
Further, some buttons such as "Jump to Assignment" and "Return to Home" would make the navigation more intuitive. I have just started a Java course and have
The JAVA_HOME environment variable points to the directory where the Java runtime environment (JRE) is installed on your computer.
Use Java coding assignments from CodeSubmit to make better hiring decisions. Discover why candidates prefer ... Spring take home assignments on CodeSubmit.
Code · Issues · Pull requests. Game Manager with Resolver – Home Assignment. java spring-boot assignment ebay home-assignment. Updated on Aug 1, 2020; Java
The easiest ways to set the JAVA_HOME environment variable on any ... If that doesn't work, try running update-alternatives --list java .
Three ways to set the JDK JAVA_HOME variable in Windows include: allow the Java installer to do it;; use the environment variable editor; and
You should see the location of your JDK installation. Now you can try running your favourite Java program and everything should work perfectly.
Steps to set the JAVA_HOME and update the PATH environment variables on Windows 10 to run programs written in Java.
This should resolve javac. In the future, authors should understand what does and doesn't work before writing a tutorial. 2.