The application (Cocos2d-x) tells that

JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-1.9.0-openjdk-amd64

My /etc/environment contains this:

export JAVA_HOME

Content of ~./bashrc:

# Add environment variable ANT_ROOT for cocos2d-x
export ANT_ROOT="/usr/share/ant/bin"

Output of whereis java:

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

Output of which 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

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

  • Run update-alternatives --list java and post the result – George Udosen Jan 6 '18 at 21:03
  • update-alternatives --list java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java – R S Jan 7 '18 at 12:10
  • Please add ant additional info to your post, please check your cocos configuration perhaps your missing a configuration. – George Udosen Jan 7 '18 at 12:37
  • @George Udosen I already managed to install Java 9 properly or almost properly, there another problems now. I think this question is not actual for me anymore. Thank you. – R S Jan 7 '18 at 15:26

Two things:

  1. This line export JAVA_HOME should not be in /etc/emvironment, then make JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 this JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-amd64", and
  2. This JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-amd64" in ~/.bashrc should be replace with these lines:

    export PATH=$PATH:$JAVA_HOME/bin
  • Thanks, but still the same. – R S Jan 6 '18 at 20:53
  • Did you do source ~/.bashrc after updating .bashrc file? – George Udosen Jan 6 '18 at 20:54
  • Yes, I did. And the same to /etc/environment. – R S Jan 6 '18 at 20:56
  • Hell no, man. After that edit I couldn't login. I removed JAVA_HOME and export lines from /etc/environment using liveCD and logged in then. – R S Jan 6 '18 at 21:56
  • I never said you should put export lines in /etc/environment sorry if you miss understood me. You edited two file and the second step was meant for the ~/bashrc file. – George Udosen Jan 6 '18 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.