Amruta Amruta - 1 year ago 112
Linux Question

How to set JAVA_HOME in Linux for all users

I am new to Linux system and there seem to be too many Java folders.

java -version gives me:

  • java version "1.7.0_55"

  • OpenJDK Runtime Environment (rhel- u55-b13)

  • OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

When I am trying to build a Maven project , I am getting error:

Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/java/jdk1.7.0_05/bin/java

Could you please tell me which files I need to modify for root as well as not-root user and where exactly is java located?

Answer Source
  1. find /usr/lib/jvm/java-1.x.x-openjdk
  2. vim /etc/profile
  3. add:

    export JAVA_HOME="path that you found"
    export PATH=$JAVA_HOME/bin:$PATH
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download