• Administering Data Integration for Oracle Enterprise Performance Management Cloud
  • EPM Integration Agent
  • Installing and Configuring the EPM Integration Agent

Setting JAVA_HOME

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:

java home assignment

java home assignment

home-assignment

Here are 4 public repositories matching this topic..., mytask1234 / ebay-game-manager.

Game Manager with Resolver – Home Assignment

ZhekehZ / SD-NBash

SoftwareDesign home assignment

mytask1234 / ubimo-home-task

Ubimo Home Task

mytask1234 / vmware-2nd-interview-DAG

VMware 2nd Interview - Create a class which represents a DAG (directed acyclic graph)

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."

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

Image titled Set Java Home Step 1

Image titled Set Java Home Step 2

Image titled Set Java Home Step 3

Image titled Set Java Home Step 5

Image titled Set Java Home Step 6

Image titled Set Java Home Step 7

Image titled Set Java Home Step 9

Image titled Set Java Home Step 10

Image titled Set Java Home Step 11

Image titled Set Java Home Step 13

Image titled Set Java Home Step 15

Image titled Set Java Home Step 16

Image titled Set Java Home Step 18

Image titled Set Java Home Step 19

Image titled Set Java Home Step 20

Image titled Set Java Home Step 21

Expert Q&A

Video . by using this service, some information may be shared with youtube..

java home assignment

You Might Also Like

Do Division in Java

About This Article

Nicole Levine, MFA

Is this article up to date?

Am I a Narcissist or an Empath Quiz

Featured Articles

Get Wrinkles Out of Polyester

Trending Articles

How to Fold a Gum Wrapper Heart in 9 Simple Steps

Watch Articles

Make Tabasco Sauce

wikiHow Tech Help Pro:

Level up your tech skills and stay ahead of the curve

java home assignment

java home assignment

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

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:

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 :

set JAVA_HOME OpenJDK

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:

Windows 7 JAVA_HOME

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."

Java PATH variable

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: 

%JAVA_HOME% bin

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

java home assignment

How do I install Java?

CameronMcKenzie

How do I install Java on Ubuntu?

java home assignment

How do I install Java on Windows?

java home assignment

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 ...

Tom Gregory logo

Tom Gregory

Scaling developer productivity

JAVA_HOME vs. PATH Environment Variables

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:

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.

java home assignment

Now press Start , type Environment , and select Edit the system environment variables .

java home assignment

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.

java home assignment

Adding JAVA_HOME

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.

java home assignment

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 .

java home assignment

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 .

java home assignment

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.

java home assignment

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.

Now you can try running your favourite Java program and everything should work perfectly.

Final thoughts

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. 👇

Get going with Gradle course

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.

IMAGES

  1. JAVA Assignment

    java home assignment

  2. Java Assignment 1

    java home assignment

  3. How to set JAVA_HOME and PATH in Linux? Example

    java home assignment

  4. JAVA Assignment Help: An Excellent Approach To Excel In JAVA

    java home assignment

  5. Setting the JAVA_HOME Variable in Windows

    java home assignment

  6. How to Set Java Home

    java home assignment

VIDEO

  1. KKHSOU BA 1st sem Education home assignment| KKHSOU home assignment BA 1st sem Education 2023

  2. M.A 1st Sem.Political Science PGPS: S102//C.Q:(2)//Home Assignment//KKHSOU//

  3. WdKA Home Assignment

  4. Demo Assignment Java 5

  5. English Home Assignment

  6. Home Assignment

COMMENTS

  1. Setting the JAVA_HOME Variable in Windows

    Set the JAVA_HOME Variable · Locate your Java installation directory · Do one of the following: · Click the Environment Variables button. · Under

  2. I give you the best 200+ assignments I have ever created (Java)

    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

  3. Setting JAVA_HOME

    The JAVA_HOME environment variable points to the directory where the Java runtime environment (JRE) is installed on your computer.

  4. Java Coding Assignments on CodeSubmit

    Use Java coding assignments from CodeSubmit to make better hiring decisions. Discover why candidates prefer ... Spring take home assignments on CodeSubmit.

  5. home-assignment · GitHub Topics

    Code · Issues · Pull requests. Game Manager with Resolver – Home Assignment. java spring-boot assignment ebay home-assignment. Updated on Aug 1, 2020; Java

  6. How to Set JAVA_HOME for JDK & JRE: A Step-by-Step Guide

    The easiest ways to set the JAVA_HOME environment variable on any ... If that doesn't work, try running update-alternatives --list java .

  7. How to set JAVA_HOME in Windows and echo the result

    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

  8. JAVA_HOME vs. PATH Environment Variables

    You should see the location of your JDK installation. Now you can try running your favourite Java program and everything should work perfectly.

  9. How to set JAVA_HOME environment variable on Windows 10

    Steps to set the JAVA_HOME and update the PATH environment variables on Windows 10 to run programs written in Java.

  10. How to set JAVA_HOME on Windows 10?

    This should resolve javac. In the future, authors should understand what does and doesn't work before writing a tutorial. 2.