2

I am using jenv to set the java home. It works fine and points to the correct JAVA_HOME when I do echo $JAVA_HOME.

My question is how do we set Intellij to get the SDK pointed by JAVA_HOME without having to go through the project SDK route.

Output of:

echo $JAVA_HOME
/Users/jetfire/.jenv/versions/ibm64-15.0.1
java -version
openjdk version "15.0.1" 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.1+9)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.23.0, JRE 15 Mac OS X amd64-64-Bit Compressed References 20201024_81 (JIT enabled, AOT enabled)
OpenJ9   - 0394ef754
OMR      - 582366ae5
JCL      - ad583de3b5 based on jdk-15.0.1+9)

I feel the closest related answer is from here https://stackoverflow.com/a/33559424

However I don't think I should be setting java_home as it is already setup by jenv.

2 Answers2

2

You don't need any variables set up. The link you provided has the answer. When you click the + button use the path that you've posted here /Users/jetfire/.jenv/versions/ibm64-15.0.1

I'm using sdkman so it's basically the same enter image description here

ALex
  • 673
  • 1
  • 6
  • 19
  • Thanks Alex. But what if I install another JDK, says ibm64-11.0.6 and then set the JAVA_HOME through jenv . I believe I would have to go through the process of setting up the SDK in IntelliJ again. I was hoping that IntelliJ will pick up the SDK in JAVA_HOME, so that if I change the jdk, say within a project folder locally (through something like jenv), the IntelliJ project within that folder would point to it automatically – graphEnthusiast Mar 27 '21 at 14:44
  • I think this si what you're looking for https://stackoverflow.com/a/33559424/3018285 but I think the level of controll you have by setting it up manually in the SDKs list is better than alwasy taking the version that you're using because imagine that you have multiple projects that use different SDKs versions. What will you do if all of them will start with the version that you use currently in JAVA_HOME? Using the SDK list in intelij will you the power to set up any number of sdk versions and use them accordingly. – ALex Mar 27 '21 at 14:58
1

Reached out to the IntelliJ team and it appears that there is an open request for this feature. Currently it is not possible to so. Reference:

  1. https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010575659-Pointing-IntelliJ-SDK-to-jenv?page=1#community_comment_360002997359
  2. https://youtrack.jetbrains.com/issue/IDEA-147078?_ga=2.66760616.724108090.1617223162-921036159.1616804110