I'm on Debian Sid.
In all places imaginable I've set the JDK to Oracle JDK8:
user@host:~$ cat .bash_profile | grep JAVA_HOME
user@host:~$ cat .bashrc | grep JAVA_HOME
export JAVA_HOME='/usr/lib/jvm/jdk-8-oracle-x64'
user@host:~$ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1069 auto mode
1 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1069 manual mode
2 /usr/lib/jvm/jdk-7-oracle-x64/jre/bin/java 317 manual mode
* 3 /usr/lib/jvm/jdk-8-oracle-x64/jre/bin/java 318 manual mode
Press <enter> to keep the current choice[*], or type selection number: 3
In "Switch IDE boot JDK..." IDE action:
In "About" menu item:
If I run xterm
with echo $JAVA_HOME
, it indeed prints /usr/lib/jvm/jdk-8-oracle-x64
, all is fine here.
Howerver, if I run echo $JAVA_HOME
in the built-in terminal in IntelliJ IDEA, I can see that $JAVA_HOME
is set to a wrong value:
user@host:~$ echo $JAVA_HOME
/usr/lib/jvm/java-1.7.0-openjdk-amd64
user@host:~$
If I run Java tests or run Maven via IDE plugin, then $JAVA_HOME
is too set to that same incorrect value (this can be demonstrated by Maven or the test runner running a test with something like Runtime.getRuntime().exec("printenv | grep JAVA_HOME");
).
This happens no matter project I open in the IDE.
In what place else can $JAVA_HOME
be accidentally set to the wrong value, /usr/lib/jvm/java-1.7.0-openjdk-amd64
?
Found it.
Did a
find / -type f -size -409600c -print0 | xargs -I{} -0 grep -sl "java-1.7.0-openjdk" {}
The guilty file was /etc/profile.d/bigtop.sh
. I have no idea why IDEA (heh) apparently ran that script. It had the following content:
export MAVEN_HOME=/usr/local/maven
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
export ANT_HOME=/usr/local/ant
export GRADLE_HOME=/usr/local/gradle
export PATH=$MAVEN_HOME/bin:$ANT_HOME/bin:$FORREST_HOME/bin:$GRADLE_HOME/bin:$PATH
export GRADLE_OPTS="-Dorg.gradle.daemon=true"
I changed JAVA_HOME
there, and it fixed my issue.