How to set environmental variable PATH?
I'm using Ubuntu 10.10
and downloaded jdk7
from java.sun.com
. That jdk
is a compressed file and on extraction there I got all the files and folders of jdk1.7.0
.
But now if I tries to compile a java
program than there is an error that javac
not found.
How could I set PATH
of jdk1.7.0\bin
to use javac
everywhere?
A better way to install the Sun JDK is like so:
- How do I install Java?
Use update-alternatives
to do all the heavy lifting for you.
In any case, updating the PATH
is a very basic command.
-
In the default bash shell:
export PATH=$PATH:/your/path
-
For csh use:
setenv PATH $PATH:/your/path
Edit: Note that this is indeed the instructions for installing Java 6 and not Java 7, which is still - as of now - not available in any official repository or ppa.
- Download the latest version of java from
java.sun.com
- Extract the file in your home folder.
-
Run the following commands in terminal
sudo mkdir -p /usr/lib/java/
sudo mv jdk1.7.0/ /usr/lib/java/
Find the file
profile
inetc
folder ofFileSystem
-
Edit in editor and write the line
export PATH=/usr/lib/java/jdk1.7.0/bin:$PATH
save it. You might need to
restart
your system to make these change.
You can check the current version using the following command javac -version
easiest way:
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get install -y oracle-jdk7-installer
I don't think you will need to bother setting the path after that.