7

I am using Linux Mint and trying to run Intellij IDEA from icon on the start menu. Starting Intellij via terminal ./idea.sh works fine. However launching from icon (points to the same ./idea.sh) ends up with following error:

No JDK found. Please validate either IDEA_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.

Running echo $JAVA_HOME and java -version works correctly and shows installed JDK. How can I fix this issue and why starting from icon differs from starting from terminal?

Dmitry K
  • 1,142
  • 2
  • 16
  • 27
  • 4
    Where are you setting `JAVA_HOME`? I'm guessing it's a file that only gets loaded by the shell in terminal windows, but not for your desktop session. That is, what is happening is: your desktop runs without JAVA_HOME set, you click on the icon, the launcher uses the environment on the desktop, breaks. You run a terminal, `.bashrc` sets JAVA_HOME, you run `idea.sh` in the terminal, then it works. – millimoose Mar 08 '18 at 15:46
  • 1
    @millimoose, I installed jdk via sdkman. I am not sure where it sets `JAVA_HOME`. – Dmitry K Mar 08 '18 at 15:47
  • Go and find out then? – millimoose Mar 08 '18 at 15:49
  • 1
    Actually, that's not necessary, we've already established that the variable is not available in your login environment and thus to the launcher, so either way you need to make it available. It's been a hot minute since I used a Linux, but can't you set environment variables on the launcher shortcut directly? Change the call to `idea.sh` to be `JAVA_HOME=/path/to/some/jdk /path/to/idea.sh`? Or set `JAVA_HOME` in `.profile` or whatever file Linux Mint loads at login. – millimoose Mar 08 '18 at 15:51
  • 1
    @DmitryKach, I think what sdkman does is to expose the JAVA_HOME every time the terminal is launched. If this is the case you will have to manually export your java home (point to sdkman files, it's OK) – lealceldeiro Mar 08 '18 at 15:58

1 Answers1

3

As @lealceldeiro and @millimoose pointed out, SDKMAN exposes JAVA_HOME every time terminal is launched. That is why JAVA_HOME was unavailable from other places. All I had to do is add JAVA_HOME to /etc/environment manually:

JAVA_HOME="/home/dmkach/.sdkman/candidates/java/current"
Dmitry K
  • 1,142
  • 2
  • 16
  • 27