[SOLVED] Why cocos refers to wrong version of JDK (Ubuntu)?

My /etc/environment contains this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

Content of ~./bashrc:

# Add environment variable ANT_ROOT for cocos2d-x
export ANT_ROOT="/usr/share/ant/bin"
export PATH=$ANT_ROOT:$PATH
JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-amd64"
export PATH=$PATH:$JAVA_HOME/bin

Output of whereis java:

java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz

Output of which java:

/usr/bin/java

Output of java -version:

openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

ls /usr/lib/jvm gives this:

java-1.8.0-openjdk-amd64 java-8-openjdk-amd64

I tried to compile from proj.android-studio/ using this:
cocos compile -p android --android-studio
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-1.9.0-openjdk-amd64

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

Error running command, return code: 1.

JDK itself works: I can compile Java programs and Android Studio’s (non-cocos).

We don’t test on OpenJDK specifically. But, I can do Android on Ubuntu 17 just fine. Android Studio, etc.

I reinstalled Ubuntu, now it compiles. With opendjk 9. Thanks for attention.