Ubuntu – Eclipse not using PATH

14.04eclipsejava

I am facing an issue of Eclipse not picking up the VM from the PATH environment variable. I follow the below steps to reproduce the error:

  1. Downloaded the appropriate version of Oracle's JDK from http://www.oracle.com/technetwork/java/javase/downloads/index.html?ssSourceSiteId=otnjp

  2. extracted it:

    tar zxvf ~/Downloads/jdk-8u5-linux-x64.tar.gz ~/DEV
    
  3. Added to PATH:

    gedit ~/.bashrc
    export JAVA_HOME=/home/faizal/DEV/jdk1.8.0_05
    export PATH=${PATH}:${JAVA_HOME}/bin
    
  4. Confirmed java is available in PATH by restarting system and executing java in random folder in bash:

    cd ~
    java
    

But when I run Eclipse, I get the error :

A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: /home/faizal/DEV/eclipse-luna/eclipse/jre/bin/java java in your current PATH

I can make it work only by creating a symbolic link java in /bin to point to $JAVA_HOME/bin/java. Why is Eclipse not working without this symbolic link?

Best Answer

According to this link:

Shell config files such as ~/.bashrc, ~/.bash_profile, and ~/.bash_login are often suggested for setting environment variables. While this may work on Bash shells for programs started from the shell, variables set in those files are not available by default to programs started from the graphical environment in a desktop session.

If you are running eclipse from your desktop session, you should modify your ~/.profile.

In this file you can also place environment variable assignments, since it gets executed automatically by the DisplayManager during the start-up process desktop session as well as by the login shell when one logs in from the textual console.

Related Question