Saturday, February 1, 2014

How to add the path of the JDK to JAVA_HOME in Linux?

If you've already installed the JDK, it's as simple as this:
type locate jdk and search for the path.

Mine was in /usr/local/jdk1.7.0_45/

So I opened up bash_profile with
vim ~/.bash_profile

and added the following line into it.
export JAVA_HOME

Also add :

So that when you execute commands like jar -xf somejar.jar, the executables will be recognized.

Then type source ~/.bash_profile to activate the changes you made (basically the whole of bash_profile will be executed again).

That's it! all programs will recognize JAVA_HOME. I had to do this for Gradle to recognize the path. Without the path, it didn't compile Java programs.

No comments: