Skip to content

Java Home

If you are getting java_home is not defined correctly in Ubuntu, then you are at right place.

I was getting this error as I was trying to update the Java home in ~\.bashrc and ~\.bash_profile. Follow these steps to solve this issue.

  1. Open the /etc/environment file as

    vim /etc/environment
    
  2. Then set java_home using

    JAVA_HOME="/usr/lib/jvm/java-8-oracle"
    export JAVA_HOME
    
  3. Open bash profile as

    vim ~\.bash_profile
    
  4. Then add the following,

    .  /etc/environment
    

    It will load the /etc/environment every time terminal is started

  5. Then confirm the path using

    echo $JAVA_HOME
    

Was this page helpful?
-->