5

I have install Java 8 EA on my Window 7, but it's neither in my %JAVA_HOME% nor in the %PATH%. However when I start my IntelliJ IDEA v12 by clicking idea64.exe, it picked up java 8 EA instead of my Java SDK 1.6.0_32, which is in the %JAVA_HOME% and %PATH%.

Anyone know when IDEA started, how it decide which Java version to run?

appbootup
  • 9,537
  • 3
  • 33
  • 65
Gelin Luo
  • 14,035
  • 27
  • 86
  • 139

3 Answers3

18

It was picked from the registry.

When launched from .exe IDEA looks for Java in a following order:

  1. IDEA_JDK (or IDEA_JDK_64) environment variable
  2. jre/ (or jre64/) directory in IDEA home
  3. registry
  4. JDK_HOME environment variable
  5. JAVA_HOME environment variable

When launched from .bat the order is same but registry isn't looked, and 64-suffixed vars aren't used (what is probably a bug).

  • which registry item? I have located JetBrain in both `HKEY_CURRENT_USER/software` and `HKEY_LOCAL_MACHINE/software`, none of them presented a JDK option. `JavaSoft` key neither have something useful – Gelin Luo Jan 07 '13 at 21:40
  • Sorry, don't have a ready answer. IDEA uses exe4j for this. There are HKCU\Software\ej-technologies and HKLM\Wow6432Node\JavaSoft keys which may be relevant. – Roman Shevchenko Jan 08 '13 at 09:23
  • Still not there. Here is my HKCU/Software/ej-technologies: http://ge.tt/8vVkmvU/v/0. And there is no Wow6432Node at HKLM or HKLM/Software at all, neither does ej-technologies found under HKLM or HKLM/Software – Gelin Luo Jan 08 '13 at 09:48
  • What do you mean "not there"? Clearly there is Java 8 in a list of JVMs known to exe4j. If you don't want it to be picked either drop all it's mentions from registry, or override it with IDEA_JDK_64 env var. – Roman Shevchenko Jan 08 '13 at 11:01
  • Yes java 8 is in the list. The question is why exe4j choose it instead of anyone else in the same list? I don't have IDEA_JDK_64 defined. So how exe4j choose it? – Gelin Luo Jan 09 '13 at 03:57
  • Because it's version number is biggest. – Roman Shevchenko Jan 09 '13 at 17:17
  • Thanks a lot for the answer. I must say though that the 64bit Idea11 uses IDEA_JDK and not the IDEA_JDK_64 variable. – Luca Molteni Dec 12 '13 at 09:35
3

Here is the available options that you can use for all the different operating systems. If you are interested.

http://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under

dawogfather
  • 604
  • 5
  • 10
  • 1
    The linked page no longer exists. It would have been better to put the relevant information directly into your answer instead of linking to it. – Mark B Mar 29 '16 at 15:53
  • It's all there Mark you just have to log in first. https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under?flash_digest=467bccd8b0182e4073a4062ed981c3723176ea9c – dawogfather Mar 31 '16 at 04:03
  • Also I do take your point Mark. Much easier to never leave SO but unfortunately it's quite a long article for all the different operating systems and options – dawogfather Mar 31 '16 at 04:05
  • Nope, I'm logged in, it still takes me to "the page you were looking for doesn't exist" – Mark B Mar 31 '16 at 11:33
  • On further inspection, I think you had some sort of session token or user ID in the URL, removing that made this URL work for me: https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under – Mark B Mar 31 '16 at 11:33
  • This link no longer exists. – Graham Polley Jan 16 '17 at 23:43
  • i came up saying it didnt work for me too but then it redirected me here https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under – dawogfather Mar 29 '17 at 09:39
0

You can add an additional environment variable called IDEA_JDK to target the specific JDK that you want Intellij to use.

Joshua
  • 26,234
  • 22
  • 77
  • 106
  • I've added the environment variable. it set the correct JDK if I launch from idea.bat, but still not good if it is launched from idea64.exe – Gelin Luo Jan 07 '13 at 02:01