Set java jdk path windows

How to set java_home on Windows 7?

You closed cmd and reopened it? Also it looks like you are pointed to the JRE not the JDK. Have you installed the JDK?

I have definitely installed the JDK and it’s located in C:\Sun\SDK\jdk\bin which I have set java_home to.

Still it seems to be looking in C:\Program Files\Java\jre6\lib\ c Can you do echo %JAVA_HOME% in your command prompt and see what it reports

18 Answers 18

Find JDK Installation Directory

First you need to know the installation path for the Java Development Kit.

Open the default installation path for the JDK:

There should be a subdirectory like:

C:\Program Files\Java\jdk1.8.0_172 

Note: one has only to put the path to the jdk without /bin in the end (as suggested on a lot of places). e.g. C:\Java\jdk1.8.0_172 and NOT C:\Java\jdk1.8.0_172\bin !

Set the JAVA_HOME Variable

Once you have the JDK installation path:

  1. Right-click the My Computer icon on your desktop and select Properties.
  2. Click the Advanced tab, then click the Environment Variables button.
  3. Under System Variables, click New.
  4. Enter the variable name as JAVA_HOME.
  5. Enter the variable value as the installation path for the Java Development Kit.
  6. Click OK.
  7. Click Apply Changes.

Note: You might need to restart Windows

The complete article is here, on my blog: Setting JAVA_HOME Variable in Windows.

thanks. finally I realized that one has only to put the path to the jdk without /bin in the end (as suggested on alot of places). e.g. C:\Java\jdk1.6.0_31 and NOT C:\Java\jdk1.6.0_31\bin !

God forbid there was an installer that did this step for you 🙂 I just switched from the Enterprise version to the Community version and I was convinced I downloaded the wrong thing because it was one-click on the Enterprise version :p

/Java/jre* is not JDK directory, this is Java Runtime Enviroment diretory. JDK is in a separate directory unless you want to do some crazy hack

What worked for me was adding the %JAVA_HOME%\bin to the Path environment variable with the JAVA_HOME environment variable pointing to the jdk folder.

You have to first Install JDK in your system.

JAVA_HOME = C:\Program Files\Java\jdk1.7.0 [Location of your JDK Installation Directory]

Once you have the JDK installation path:

  • Right-click the My Computer icon on
  • Select Properties.
  • Click the Advanced system setting tab on left side of your screen
  • Aadvance Popup is open.
  • Click on Environment Variables button.

enter image description here

  • Under System Variables, click New.
  • Enter the variable name as JAVA_HOME.
  • Enter the variable value as the installation path for the Java Development Kit.
  • Click OK.
  • Click Apply Changes.

Set JAVA Path under system variable

PATH= C:\Program Files\Java\jdk1.7.0; [Append Value with semi-colon]

check here

Should JAVA_HOME contain «\bin»? Other answers here seem to suggest «bin» should be included for PATH but not for JAVA_HOME.

In cmd (temporarily for that cmd window):

set JAVA_HOME="C:\\. \java\jdk1.x.y_zz" echo %JAVA_HOME% set PATH=%PATH%;%JAVA_HOME%\bin echo %PATH% 

True. If you use setx then the JAVA_HOME will still be set after you have shutdown your computer. Then you don’t have to set it again. Also bin is not needed.

Yes, but if you don’t want to officially install Java, then as sgrillon said, you can set it temporarily for that instance. Better yet, create a batch file that you can run to open a command-prompt window and set JAVA_HOME , PATH , and CLASSPATH , then you can have a “portable” Java environment.

You need to set it to C:\Sun\SDK\jdk (Assuming that is where the JDK is installed — It is not the default) — Do not put the \bin in C:\Sun\SDK\jdk\bin .

If your app only runs when you are logged in as the current user then put it in the user variables — If it needs to run for all users on your system then put it in System variables.

You might also need to add %JAVA_HOME%\bin to the path also (Also it depends on whether you run it from just the user or from all users, including System)

Control Panel > Java, Java tab, click the View button. In Runtime Parameters, put:

Or when you execute Java you can add that command line switch to the command:

java -Djava.home=PATH SomeJavaApp 

Th control panel thing seems to apply for the commercial version of Java only. Not for the GPL version.

enter image description here

One Image can fix this issue.

For those who are still stumped with this problem (I tried all the above suggestions) —

If you’re on a 64-bit version of Windows and you’ve installed the 32-bit JDK, besides adjusting PATH variables, you may need to adjust registry variables, too.

I was pulling my hair out, having correctly set my PATH variables — still to no avail — and then only finding «vacated» Java entries in my registry, seemingly a deadend of fixing the «misfiring» Java Runtime Environment.

By using Process Monitor to watch the program I was trying to get started, in order to sniff out where it was looking in the registry for Java (Runtime Environment), I triumphantly discovered that it’s looking in the 32-bit version of registry entries, found in HKEY_LOCAL_MACHINE\SOFTWARE\**Wow6432Node**\JavaSoft\Java Runtime Environment .

Within that key, you should find subkeys of different Java versions installed (past and/or present). Click on the subkey of the latest version (my subkey is currently 1.7.0_25, for example). After clicking on that subkey, you’ll see registry string values listed on the right, and particularly, JavaHome and RuntimeLib . You need to modify the values of those two values to reflect the both the current folder and jvm.dll file, respectively.

For example, in my case, the values were (previously) respectively set at C:\Program Files (x86)\Java\jre7 and C:\Program Files (x86)\Java\jre7\bin\client\jvm.dll which are nonexistent on my machine. I had to update these to the current folder and file of C:\Program Files (x86)\Java\jdk1.7.0_25\jre and C:\Program Files (x86)\Java\jdk1.7.0_25\jre\bin\client\jvm.dll .

Again, this will depend entirely on both what version of Java (JDK and/or JRE) you have installed — 32 or 64-bit — and what type of operating system you’re on — 32 or 64-bit. Just know that they’re reflected in different locations within the registry (like the Wow6432Node for 32 bit applications, in my case with the 32-bit JDK installed on a 64-bit machine).

Now that I’ve updated those two registry values, my program runs flawlessly, with no more hiccups or complaints about a missing Java Runtime Environment (stemming from the registry).

I am on 64-bit windows 7 machine and I have both : C:\Program Files (x86)\Java\ and C:\Program Files\Java\ Now my question is that which one should my java_home point to ?

Under C:\Program Files (x86)\Java\jdk1.7.0_25\jre\bin I dont have directory client, it only exist under C:\Program Files (x86)\Java\jre7\bin. What should I do?

On windows 7, after searching for keyword «1.8.0_74», I found multiple registries using regedit in HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java Development Kit/1.8.0_74/ or ../1.8.0_65 and all other installed previously. After deleting one by one registry from bottom to my latest installed java 1.8.0_112, now YourKit java profiler (profiler.exe) works without error: «Error occured while starting C:\Program Files\Java\jdk1.8.0_74\bin\javaw.exe» .

This is the official solution for setting the Java environment from www.java.com — here.

There are solutions for Windows 7, Windows Vista, Windows XP, Linux/Solaris and other shells.

Example

Windows 7

  1. Select Computer from the Start menu
  2. Choose System Properties from the context menu
  3. Click Advanced system settings -> Advanced tab
  4. Click on Environment Variables, under System Variables, find PATH, and click on it.
  5. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
  6. Reopen Command prompt window, and run your Java code.

The official instructions are useless. They only give generic instructions on how to set environment variables rather than indicating the value that needs to be set. They simply say to set it to “the location of the class” which is confusing and meaningless.

These instructions do not set JAVA_HOME, an entirely separate variable from PATH that is required for some programs.

Windows 7

  1. Go to Control Panel\All Control Panel Items\User Accounts using Explorer (not Internet Explorer!) or
    • click on the Start button start
    • click on your picture clickOnPhoto
  2. Change my environment variablesChange my environment variables
  3. New.new (if you don’t have enough permissions to add it in the System variables section, add it to the User variables section)
  4. Add JAVA_HOME as Variable name and the JDK location as Variable value > OK edit system variable ok
Оцените статью