Thursday, January 8, 2015

Where is your java distribution running on Ubuntu ?

There are couple of ways to getting Java running on Ubuntu. Some are extract the Java binary distribution and changing system files to thing get effected. Some are using apt-get install utility to Java distribution get running on Ubuntu. So in this blog post I am not going to discuss about how to get Java running on Ubuntu. 

You may actually not know where is Java distribution folder extracted and running, I mean which path if you installed it using apt-get utility. Even you may forget with the time being, specially like me ;-) if you extracted Java binary in a exact path that you want. I faced same situation and need to find out where is my Java distribution running. So I found the below command which exactly tell you the path.


readlink -f $(which java)

2 comments:

  1. I can get the same result just using ' which java ' command. Why do you need to use ' readlink ' ?

    ReplyDelete
    Replies
    1. 'which java' return symlink not actual path if you properly configure JDK with following set of commands.

      $ sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.6.0_45/bin/java" 1
      $ sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/jdk1.6.0_45/bin/javac" 1
      $ sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/opt/jdk1.6.0_45/jre/lib/amd64/libnpjp2.so" 1
      $ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/jdk1.6.0_45/bin/javaws" 1

      $ sudo update-alternatives --config java
      $ sudo update-alternatives --config javac
      $ sudo update-alternatives --config javaws

      Delete