Path java win 10

How to set JAVA_HOME in Windows 11/10

In Unix terminology, an Environment variable is a string that holds information such as drive name, pathname, filename, etc. JAVA_HOME is an environment variable which addresses to the directory where Java Runtime Environment or Java Development Kit is installed in the system. To be precise, say if you have installed Java in the path C:\Program Files\Java\jdk1.8.0_121 on your computer, then your Java_Home is C:\Program Files\Java\jdk1.8.0_121. Basically, JAVA_Home is simply an exemplary used by Java-based programs like Apache Tomcat and other app server tools to find where Java is placed in the system.

These third-party programs make use of the environment variables that point to the directory of JDK or JRE. In simple words, it makes easy for the programs to locate the directory executable like javac in the computer. If you are not using these third-party programs, then it may not be mandatory for users to set up JAVA_Home in your system. In this article, we will explain in detail how to set JAVA_HOME as the environment variable in Windows 10.

Setting JAVA_HOME in Windows 11/10

Set JAVA_HOME environment variable & update the system path

Download and install Java from the official site – java.com.

After installation, Go to Start menu and type Advanced system settings.

Click on View advanced system settings from the list to open System Properties.

Go to Advanced tab and click on Environment Variables button.

In the Environment Variable window, click on New button under the System variable.

In the Edit System Variable, give the Variable name as JAVA_HOME and Variable value as the path to your JDK directory.

Click on OK.

Now go back to the Environment Variable window and select Path under the System variable.

How to set JAVA_HOME in Windows 10

Click on Edit button to open Edit environment variable window.

Click on New button and type %JAVA_HOME%\bin.

Click OK to apply the changes.

Check JAVA_HOME configuration setup using CMD

To test your configuration, open Command prompt.

Type echo %JAVA_HOME% and hit Enter. This should print the directory of the JDK which the JAVA_HOME is pointing. Instead, if you see a space, it means you have failed in setting up environment variable.

Next Type javac -version which should print the version of Java compiler.

If not it will print a message that the javac is not recognized as an internal or external command. This means the path variable is not set correctly.

Источник

How to set JAVA_HOME environment variable on Windows 10

In this article, you will understand the details about JAVA_HOME environment variable and how to set it on Windows 10.

What is JAVA_HOME?

By convention, JAVA_HOME is the name of an environment variable on the operating system that points to the installation directory of JDK (Java Development Kit) or JRE (Java Runtime Environment) – thus the name Java Home. For example:

JAVA_HOME = c:\Program Files\Java\jdk1.8.0_201

Why is JAVA_HOME needed?

Читайте также:  Python if os path isfile

To develop Java applications, you need to update the PATH environment variable of the operating system so development tools like Eclipse, NetBeans, Tomcat… can be executed because these programs need JDK/JRE to function. So the PATH environment variable should include JAVA_HOME :

PATH = Other Paths + JAVA_HOME

Other paths are set by various programs installed in the operating system. If the PATH environment variable doesn’t contain a path to JRE/JDK, a Java-based program might not be able to run. For example, typing java in the command prompt showing this error:

'java' is not recognized as an internal or external command, operable program or batch file.

error java command

Or Eclipse will fail to launch:

Eclipse launch error no Java home found

How to set JAVA_HOME on Windows 10

Here are the visual steps to properly set value for the JAVA_HOME and update the PATH environment variables in order to setup Java development environment on your computer:

1. Firstly, you need to identify the Java home directory, which is typically under C:\Program Files\Java directory. Open My Computer and navigate to this directory, you will see:

Java home directory

Here, the home of JDK is under C:\Program Files\Java\jdk1.80_201 . The version number may vary, depending on the JDK you installed.

2. Open the System Environment Variables dialog by typing environment in the search area on Start menu. Click the suggested item Edit the system environment variables:

start menu open system environment variable dialog

The System Properties dialog appears, click the button Environment Variables.

System properties dialog

Then you will see this dialog:

Environment Variables dialog

3.Create the JAVA_HOME environment variable by clicking the New button at the bottom. In the New System Variable form, enter the name and value as follows:

New JAVA HOME system variable

Click OK, and you will see the JAVA_HOME variable is added to the list.

4.Update the PATH system variable. In the Environment Variables dialog, select the Path variable and click Edit:

Edit Path variable

Then in the Edit environment variable dialog, double click on the empty row just below the last text line, and enter %JAVA_HOME%\bin as follows:

Edit Path variable for Java home

The percent signs tell Windows that it refers to a variable – JAVA_HOME , and the \bin specifies the location of java.exe and javac.exe programs which are used to run and compile Java programs, as well as other tools in the JDK.

Click OK button to close all the dialogs, and you’re all set. Now you can open Eclipse or NetBeans to verify. Or open a command prompt and type in javac –version , you should see:

verify java home

You can add the path to the bin directory of Java home directly into the PATH variable. But it’s strongly recommend to follow the above steps to setup a JAVA_HOME variable because many Java programs depend on it.

When you installed a JDK, you might not need to update the system variable because the installer already did it for you.

About the Author:

Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.

Add comment

Comments

Thank you for this helpful article !
With your help I managed to get rid of an annoying message poping every minute.

Thanks, Minh. I was having a fit getting jEdit to work despite Java being installed. The alternate method adding the literal path did not work. Your method with JAVA_HOME does work.

Читайте также:  Прыгающая стрелка вниз css

Источник

How To Install Java on Windows 10 Step by Step

In this short tutorial, we’re going to take a close look at how to install Java on Windows 10.

We’ll first start with a little insight into how to download Java. Then, we’ll explain how to install it on Windows 10. Then, we’re going to see how to properly set JAVA_HOME environment variable.

Lastly, we’ll highlight different ways to check Java and JDK versions on Windows 10.

Download Java for Windows 10

In this section, we’re going to cover in-depth all the steps required to download Java for Windows 10.

As a matter of fact, downloading Java is a piece of cake. It’s just a matter of a few clicks and simple one-time steps.

First, we need to visit the official oracle download page and choose the right release for the Java SE Platform. At this point in time, the latest version is Java 18.

Secondarily, we need to click on the Windows tab.

Bear in mind that Oracle has dropped the support for 32 bit systems. As a result, we can use Java SE only in 64 bit machines.

Oracle offers three options to install Java on Windows. We can use a compressed archive file, a x64 Installer or a x64 MSI Installer.

For instance, let’s choose the x64 Installer option:

download Java Windows 10

Before Java 17, we had to accept the Oracle Technology Network License Agreement to proceed to the next step, which is not the case for Java 18

Lastly, a simple click on the download link will do the job. Easy, right?

Install Java on Windows 10

Now that we downloaded Java for Windows 10, let’s see how to install it.

Basically, the process of installing Java on Windows 10 is pretty easy and simple.

In general, we don’t need to change anything during the installation, we can go with the default settings and follow the suggested instructions.

Firstly, we need to double click on the downloaded installer file to start the installation process:

Install Java Windows 10

Secondarily, we click Next to continue:

Choose Java installation folder

Note that, “C:\Program Files\Java\” is the default Java installation folder! However, we can always change it if we want that.

Then, we keep hitting Next until the installation is complete:

Close installation wizard

Finally, we close the installer wizard to complete the installation.

Set Java Path in Windows 10

Now that we have installed Java with success, it’s time to proceed to the next step.

In this short chapter, we’re going to dive deep into how to set JAVA_HOME environment variable on Windows 10.

Add JAVA_HOME

The basic idea behind setting the Java Path is to make all the Java commands like java and javac accessible from everywhere. That way, we can run Java programs from anywhere.

Please note that, JAVA_HOME should point to the JDK not the JRE.

First, let’s open the Advanced System Settings. To do that, we just need to press Windows key + Pause Key.

Alternatively, we can type View advanced system settings in the search box.

Search advanced system settings

Once the System Properties window is opened, we click on Environment Variables:

Open Environment Variables

Secondarily, we click on the New button to create a new environment variable with JAVA_HOME as name and the path to the JDK directory as value:

Add Java home

As we can see, the JAVA_HOME environment variable points to the JDK folder which C:\Program Files\Java\jdk-18.0.1.1 is in our case.

Читайте также:  Save all failed java lang nullpointerexception

Append JAVA_HOME to PATH

Next, we need to update the PATH variable by adding a new entry for %JAVA_HOME\bin%:

Set up Java Path on Windows 10

Finally, we can click OK to save and apply the changes.

That’s all we can say about downloading and installing java on windows 10. Now, we’re ready to write our first Java program.

Check Java Version on Windows 10

There are multiple ways that we can use to check Java version on Windows 10. The most obvious and basic way is to use the terminal.

Firstly, press Win+R and type cmd to open the Command Prompt. After that, type java -version and press Enter:

 C:\Users\Asus>java -version java 18.0.1.1 2022-04-22 Java(TM) SE Runtime Environment (build 18.0.1.1+2-6) Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing) C:\Users\Asus> 

The output means that Java is properly installed on our operating system.

Alternatively, we can type “Java” in the search box and click on “About Java”:

Check Java Version on Windows

Please bear in mind that multiple versions of JDK can be installed on the same on Windows 10 machine. So, it’s important to make sure the JAVA_HOME environment variable points to the right JDK release.

Let’s open a new command prompt and type:

 C:\Users\Asus>echo %JAVA_HOME% C:\Program Files\Java\jdk-18.0.1.1 C:\Users\Asus> 

As show above, the environment variable JAVA_HOME points to the directory of the lastest JDK version.

We can also use javac -version to verify the version of the installed JDK:

 C:\Users\Asus>javac -version javac 18.0.1.1 C:\Users\Asus> 

Another important thing to note here is that the JDK version can be different from the JRE version on the same machine.

Please keep in mind that we need always to check for new Java updates and install them to keep our machines up-to-date with the latest releases.

In case you want to check how to enable Java on Chrome and other browsers, feel free to take a look at this article: https://devwithus.com/enable-java-chrome/

Write First Java Program

Now that we installed Java, let’s see how to create our first Java program.

To do so, let’s open an IDE or a text editor of your choice, for example, Notepad++, and create a new file (ctrl+n).

Next, we need to append the following code in our newely created file:

 class HelloTest < public static void main(String args[])< System.out.println("Hello Test"); > > 

Write Java program on windows

Now, let’s save our file anywhere we want under the name: HelloTest.java

In order to execute our Java program, we need to compile it first. So, let’s open a terminal and type:

 C:\Users\Asus\Workspace\Java>javac HelloTest.java C:\Users\Asus\Workspace\Java>dir Directory of C:\Users\Asus\Workspace\Java 06/19/2022 02:26 PM 422 HelloTest.class 06/19/2022 02:25 PM 103 HelloTest.java 2 File(s) 525 bytes 2 Dir(s) 31,034,630,144 bytes free 

Compile Java file

As we can see, javac creates a new file with the name HelloTest.class. This means that the compilation phase is done with success.

Lastly, let’s run our Java program using the java command:

 C:\Users\Asus\OneDrive\Bureau\Java>java HelloTest Hello Test C:\Users\Asus\OneDrive\Bureau\Java> 

Please bear in mind that we don’t need to specify the extension when executing a Java file.

Conclusion

In this article, we’ve explained how to tackle the challenge of downloading and installing Java on Windows 10. Then, we’ve seen how to add JAVA_HOME and append %JAVA_HOME\bin% to the Path.

Lastly, we have showcased how to verify and check the installed Java version.

Thanks for reading. Have a nice day!

Liked the Article? Share it on Social media!

Источник

Оцените статью