19

For every other StackOverflow question that's been asked about this, here, here, and here, I've followed all the steps to resolve this issue, and none have worked.

When launching IntelliJ IDEA 64-bit on my 64-bit Windows 7 machine, I encounter the following error:

The environment variable JAVA_HOME (with the value of "C:\Program Files\Java\jdk1.8.0_74") 
does not point to a valid JVM installation.

Error launching IDEA

However, the file path does exist:

Filepath screenshot

And in my Environment Variables, I have set JAVA_HOME to that location:

Environment Variables

I've tinkered around with putting it in my User variables instead of the System and vice-versa, and tried putting it in both. It didn't work with the Java 7 JDK I had originally, so I just downloaded the Java 8 JDK and tried it - no dice.

I also restarted my computer, and CMD can use java and javac with no problem at all:

enter image description here

Any help on how I could resolve this? My last resort is uninstalling and reinstalling IntelliJ, which I may have to do.

Community
  • 1
  • 1
homersimpson
  • 4,124
  • 4
  • 29
  • 39

10 Answers10

16

In my case, the issue was that JAVA_HOME was pointing to a path upto /bin folder (C:\Program Files (x86)\Java\jdk1.8.0_91\bin\) - while Eclipse accepts this, IntelliJ does not.

Updating to JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_91 resolved the issue.

Tharif
  • 13,794
  • 9
  • 55
  • 77
Sachin Lala
  • 715
  • 1
  • 8
  • 18
13

The java and javac executables are using the PATH environment variable, while intelliJ is using JAVA_HOME variable. Remove the additional quotation marks in your JAVA_HOME value.

It might shows that your path to the jdk installation directory is hard coded in the PATH, rather then using %JAVA_HOME%.

Shmulik Klein
  • 3,754
  • 19
  • 34
  • 1
    Ah, I didn't know the quotes would cause such a hassle, since in CMD it wants you to surround a file path with spaces in it with quotes. This did fix it - thanks! – homersimpson Mar 22 '16 at 16:24
3

The problem will almost certainly be with the quotation marks around your JAVA_HOME path. Remove those and see if it works. If not, then I would recommend only putting your JDK installations under the root and with no spaces in them. I tend to put them in C:\JDK\1.8.0_65, etc. It makes referencing them far easier and you don't have to worry about quotation marks to protect spaces like you do with "Program Files".

ManoDestra
  • 6,325
  • 6
  • 26
  • 50
  • Yeah, I hate that Windows allows spaces in file paths. In Linux it's much easier to not have those, and underscores would work better than spaces. – homersimpson Mar 22 '16 at 16:26
  • @homersimpson Agreed. Hate spaces in file paths. Even on Windows, I don't use them where I can avoid it. Saves so much trouble and makes writing scripts/code far less prone to error. – ManoDestra Mar 22 '16 at 16:29
1

I faced the same issue.. My mistake was I was taking the path till /bin/ and putting ; at last.

Correct is - JAVA_HOME=C:\Program Files\Java\jdk1.8.0_92

no /bin/ no ';'

Pardeep Sharma
  • 572
  • 5
  • 20
1

Had the same issues opening PHPSTORM from command line. Solution was to download jdk version 8 x86(32bit). Edit settings in Environment Variables by setting JAVA_HOME path in user variables for... to C:\Program Files (x86)\Java\jdk1.8.0_221

I.Trisha
  • 11
  • 2
0

Open a CMD window, and enter:

echo %JAVA_HOME%

Verify the result is indeed the path entered your JAVA_HOME variable, i.e. C:\Program Files\Java\jdk1.8.0_74.

In my case, a space was slipped in, that was not visible in the Envrironment Variables window.

ArtOfCode
  • 5,702
  • 5
  • 37
  • 56
0

My problem was adding 2 path in JAVA_HOME variable (I had added x64 jdk path with x86 jdk and my android studio needed just the x86 one. I deleted the x64 path and it has just worked :)

Mahdieh Shavandi
  • 4,906
  • 32
  • 41
0

The problem I had seemed to be due to attempting to launch idea.exe rather than idea64.exe - when I moved to the 64 one then it worked.

Straff
  • 5,499
  • 4
  • 33
  • 31
0

Since this question appeared in my google search, and none of the aforementioned answers worked for me - here is my resolution.

What worked for me was changing \ to / in path.

So in my case it was: C:/Program Files/Java/jdk-11.0.11/ :)

Karolina Ochlik
  • 908
  • 6
  • 8
-1

You can also change the installation of OpenJDK (if you still have the installer packages) and add the JAVA_HOME variable (you have to enable it), afterwards just click through the installation until it is finished.

Den
  • 1