In this example, we will show you how to install JDK 7 on Ubuntu 12.
1. Find Openjdk
Ubuntu is using OpenJDK, in terminal, issue this command apt-cache search openjdk to get all the available Openjdk version.
$ apt-cache search openjdk
default-jdk - Standard Java or Java compatible Development Kit
default-jdk-doc - Standard Java or Java compatible Development Kit (documentation)
default-jre - Standard Java or Java compatible Runtime
default-jre-headless - Standard Java or Java compatible Runtime (headless)
icedtea-7-jre-jamvm - Alternative JVM for OpenJDK, using JamVM
icedtea-7-plugin - web browser plugin based on OpenJDK and IcedTea to execute Java applets
openjdk-7-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-7-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-7-doc - OpenJDK Development Kit (JDK) documentation
openjdk-7-jdk - OpenJDK Development Kit (JDK)
openjdk-7-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-7-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-7-jre-lib - OpenJDK Java runtime (architecture independent libraries)
openjdk-7-source - OpenJDK Development Kit (JDK) source files
java-package - Utility for creating Java Debian packages
2. Install Openjdk
To install, type this – apt-get install openjdk-7-jdk.
$sudo apt-get install openjdk-7-jdk
3. Verification
Ubuntu installed the JDK in this folder – /usr/lib/jvm/jdk-folder, for example /usr/lib/jvm/java-7-openjdk-amd64/. In additional, Ubuntu also puts the JDK bin folder in the system path, via symbolic link. For example, /usr/bin/java.
To verify if JDK is installed properly, type java -version.
$java-version
java version "1.7.0_09"
OpenJDK Runtime Environment (IcedTea7 2.3.3) (7u9-2.3.3-0ubuntu1~12.10.1)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
4. Post-Installation, JAVA_HOME
This step is optional, but recommended. To configure the JAVA_HOME in system path each time the terminal is started, just append the export JAVA_HOME to the end of /etc/profile or .bashrc.
For example.
$ echo $JAVA_HOME
//show nothing
$sudo echo export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64/" >> ~/.bashrc
//restart terminal or use "source"
$ source ~/.bashrc
$ echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64/
Done.
Leave a Reply
its really a helpful post
for those who are looking to install SUN/Oracle jdk chk this –>> http://www.wikihow.com/Install-Oracle-Java-JDK-on-Ubuntu-Linux
Sir
sachin@sachin-Lenovo-G550:~$ java -version
java version “1.7.0_21”
OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-1ubuntu1)
OpenJDK Server VM (build 23.7-b01, mixed mode)
when I apply this command this showe that java is installed in my system,but when I am going to compile any java program it gives the following error
sachin@sachin-Lenovo-G550:~/programs$ javac abc.java
The program ‘javac’ can be found in the following packages:
* default-jdk
* ecj
* gcj-4.6-jdk
* gcj-4.7-jdk
* openjdk-7-jdk
* openjdk-6-jdk
Try: sudo apt-get install
please tell me how to get rid of it & run my java program
Weird… Ubuntu should copy the Java/bin folder to your system path automatically. Nvm, just put the JAVA/bin folder to your environment.
export PATH=$PATH:$JAVA_HOME/bin
always interesting. Thanx for posting
a little remark.
you can correct
opt-cache search openjdk
with
apt-cache search openjdk
I even copied and pasted half asleep haha
Thanks for the typo, article is updated.
I loved as much as you will receive carried out
right here. The sketch is attractive, your authored subject matter stylish.
nonetheless, you command get bought an impatience over that
you wish be delivering the following. unwell unquestionably come
more formerly again as exactly the same nearly a lot often inside
case you shield this increase.
You probably forgot to close
tag after "JAVA_HOME" in your blog. It has messed up the formatting below line "in system path each time the terminal is started,"...Thanks, fixed.
oops..! it picked up
tag and screwed my comment's formatting also.[…] apt????(??) […]
[…] http://www.mkyong.com/java/how-to-install-java-jdk-on-ubuntu-linux/ […]
hiiiiiiiiiii i won’t get correct result of how to open ecllipse in linux(ubuntu)
please check the root directory once
First check your internet connection, if it’s working do as follows.
>sudo apt-get update
>sudo apt-get install sun-java6-jdk
or
check http://bgkavinga.blogspot.com/2011/09/start-up-minicom-sudo-minicom-s.html
for offline installation.
This will be use full if you have no internet access in your machine.
Thanks a lot for the instruction. I just downloaded some java plugins into my ubuntu. What folders to put them to in order to be compiled by javac to the correct path.
Sun/Oracle java is no longer in ubuntu or supported, install it from tarball from there website… or this PPA:
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk
To install Oracle Java 7 and 6 on Ubuntu 12.04 this post will help
http://suhothayan.blogspot.com/2012/04/how-to-instal-java-in-ubuntu.html
Thank you GGG, working perfectly. :D
is that all u do?
I tried many times for installing java as same code as Windows….but not to do that..
But It is easy as according to your Instruction.
Thank u…
Thank you!
Hi from Catalonia! mkyong you save my java developments and when I want something for linux it seems your web is also the best… Congratulations for your web and keep on!!!
Thanks for your kind words, and good to know it help. Actually, mkyong.com did not provides many articles on *nix, will try publish more in future.
[…] then update. Useful links: http://rsbuddy.com/forum/%5Bguide%5D-how-run-rsbuddy-linux-117146.html How to install java jdk on ubuntu (linux) Spoiler: iDungeon Pro :: Runescape Botting VPS Sythe.org – Runescape Cheating […]
thankzzzz!
[…] http://www.mkyong.com/java/how-to-install-java-jdk-on-ubuntu-linux/ […]
This will work, but the proper way to do this is to use…
sudo apt-get install sun-java6-jdk sun-java6-jre
to install jdk use this
sudo apt-get install openjdk-6-jdk openjdk-6-jre
Looks like oracle just changed the package names to get rid of ‘sun’ from the name.
The apt-get install sun-java6-jdk sun-java6-jre doesn’t work for me , i use openjdk and now i have jdk on my system
thanks alot
Open JDK is a different package entirely: http://openjdk.java.net/
Although it works for almost everything you’d want to do.
export JAVA_HOME=”/usr/lib/jvm/java-6-sun-1.6.0.06;”
I guess you don’t need a semicolon here, do you?
Thanks, article is updated.
thanks akumu for your tips. i dont know why java dont make self installing setup file like windows.
[…] source […]
i think you forgot to append this to bashrc
export PATH=$PATH:$JAVA_HOME/bin
thanks to kishore and his links….. i could install jdk without internet connection on my machine.
http://kishor15389.blogspot.com/2010/11/install-jdk-on-ubuntu-any-version.html
[…] JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.06;" Ported from: How to install java jdk on ubuntu (linux) function fbs_click() […]
IF U ARE LOOKING TO INSTALL JDK WITHOUT INTERNET CONNECTION.!IT IS POSSIBLE
IF DOWNLOAD IT FROM OTHER SYSTEM WHICH HAVE INTERNET…
IT TAKE FEW STEPS TO INSTALL THAT..
FOR MORE DETAILED STEPS PLEASE VISIT FALLOWING LINK:
http://kishor15389.blogspot.com/2010/11/install-jdk-on-ubuntu-any-version.html
I’M SURE IT DEFINITELY WORKS…
what means “remastering sys “