I have never used Ubuntu before. How do I go about setting an environmental variable that points to JDK? I installed it on my Desktop. I typed in "EXPORT JAVA_HOME=~/Desktop/jdk" in the command prompt but it didn't work.
In addition to xpt's answer:
JAVA_HOME is used internally for some things by the Java runtime. In order to run java
or javac
or other commands to start with, you need to add the directory those command are in to your path. For example:
export PATH=$PATH:~/Desktop/jdk/bin
It should work at least in the command prompt session that you just set. Else your ~/Desktop/jdk
might not be the correct setting.
To be cautious, do the following:
- Open up a command prompt
- Type in
export JAVA_HOME=~/Desktop/jdk
- Try run
java
, it should be working by now.
If so, do the following:
- Still under the command prompt.
- Type `echo "export JAVA_HOME=~/Desktop/jdk" >> ~/.bashrc
- Log off and log back in
- Open up a command prompt
- Try run
java
, it should be working by now. - Anything else (e.g. eclipse) should also be working by now.
HTH
-
-
Technically speaking, you should actually have the
export
in your.bash_profile
and have.bash_profile
source your.bashrc
on login. (.bashrc is generally sourced on spawning a shell - so an update to the file [as you suggest] should mean that a logout/in isn't necessary - just open a new shell, .bash_profile is sourced on login). I approved an edit to correct "EXPORT" to "export", but others must approve before it's updated. – nerdwaller Jun 30 '13 at 23:16 -
thanks @nerdwaller. Yeah,
export
incorrectly use asEXPORT
might be the reason why OP failed. – xpt Jun 30 '13 at 23:29
export
. – Dennis Jun 30 '13 at 23:04