Here is just an example of how to install java 7 on your linux.
I use current Debian and oracle (former sun) java 7.
First i had to download the latest java from oracle site and then extract it. I have to do it because at the moment the is no official debian package for java 7.
So we are not able to do it with apt-get as we can it for java 6.
wget http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz tar zxvf jdk-7-linux-x64.tar.gz -C /usr/lib64/jvm/
Then we have to do some configuration.
Debian Linux has useful script to maintain different version of one programs like java called update-altenatives. So i simply use this.
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/bin/java 1065 update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac 1065
Where 1065 is a given priority.
To check my installation i use –config paramter
update-alternatives --config java #this prints: There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/jdk1.7.0/bin/java 1065 auto mode 1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode 2 /usr/lib/jvm/jdk1.7.0/bin/java 1065 manual mode</pre>
And because 1065 is higher than 1061, the fresh installed java 7 will be used by default on my machine
java -version #prints: java version "1.7.0" Java(TM) SE Runtime Environment (build 1.7.0-b147) Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
Hope this save somebody some setup time.
Thank you very much! Works like charm!
Thank you very much! You saved me a lot of time!
To automate the download using WGET, use:wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" -O jdk-7-linux-x64.tar.gz "http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz"
Works Perfect!
Thank you Dude! ;))
Latest blog post: Installation and Configuration of Sonatype Nexus
Thanks!
Thank you so much - I spent hours trying to figure this out, and I was completely lost before you helped!
Thanks man. You're cleared my head a lot. Yep. Good Christmas for u and all family.
"... download the latest java from oracle site and then extrat it. "
Should that be "extract it"?
@DebianDummy Thank you. Fixed now.
Latest blog post: Installation and Configuration of Sonatype Nexus
Really helpful. Thanks...
How do I tell APT that java is installed? I want to install a package that requires java and now it always wants to download openjdk-6-jre and shit.
@adacenter07
Meanwhile there are several packagess availabel that you can install with apt. Look here: http://wiki.debian.org/JavaAnd if there is a package with a dependency to openjdk-6-jre you can isntall it with:
$apt-get install openjdk-6-jreAnd I do not think that there is another way to say apt "installed" than to perform the installation of desired package.
Latest blog post: ch1
Gracias, excelente!!! Saludos from Santiago de Chile
Yes, of course. But it's different branch: openjdk ;)
You can also do it an even more debian way with java-package: http://wiki.debian.org/JavaPackage/dontfollow ….but only fro debian wheezy onwards I should add.
Thank you. After a full day of trying install different Javas ( and making quite a mess), I found your post. I'm trying jre1.7.0_05. Fingers crossed... Thanks again, Jay
Thank you!
Thank you. I didn't know that update-alternative tool this will help me in the future.
my questions: (it doesn't have to do anything with this blog btw) 1) I have to log in on an internet site for work. This site java. I contact the site through a browser. Would speed be better if I could avoid the use of the browser, and contact the site directly. If yes, could you point out a direction of a (Java)solution. 2) Are there particular settings to improve performance of java jre?
Hallo AW. Your qustion is fussy. -Some system -Something with java. I can't answer it properly. Please more details! ;)
Shuron, Appreciate the way your explanation. I may have two other subjects for your blog. First of all, I am a newbie getting lost pretty fast in the technical explanations. So sollutions which I can understand are difficult to find. Suggestions for a blog: - How to optimise performance of java? (response, latency, etc.) - The second one is actually more of a question. I have to log in via the internet (and thus a browser) to an other computer. This computer has a java interface and java screen. Would "a more" direct link (avoiding the browser) improve performance of java? It does not fit this blog, so take it out if you please. Would appreciate your thoughts though. AW
Hi, you usually will not need Javaw (Java Viewer) if you don't know what it is. This will help you with enabling java-plugin in chrome on linux. But i didn't tried.
Quick response, thank you! In addition to your update-alternative lines (java, javac), I found an other one on an other website...Javaw..? Important? I am not out of the woods yet. Although Java seems to be installed, I can not find a way to activate it for Google chrome. Any suggestions? cheers
Hi, nice to here this helps someone. To you question: No, it should not interfer. just use one or another, if installed correct no iterference problems should appear. And you can remove openjdk with your packet manager if you installed it that way. E.g: apt-get purge openjdk-\*
Shuron, Took me all day to get sun-java into debion wheezy. Your post made it work. Question though: doesn't java 7 interfere with openjdk? How to remove openjdk the best way? Suggestions? cheers and thanks!
jdk-7u4-linux-x64.tar.gz jre-7u4-linux-x64.tar.gz I am trying to install those two above! I have managed to extract them into lib64/jvm folder, the linking fails, the method you have outlined in linking is to the lib folder : /usr/lib/jvm/ while the extraction is directed to lib64/jvm, is that a problem, as how would you modify the script for the jdk-7u4, in the usr/lib/jvm/jdk1.7.0 This the error I get alternative path /usr/lib/jvm/jdk1.7.0_4/bin/java doesn't exist
you just have to click on accept license, no big deal. anyway try wget this: http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz
“accept license agreement” & “registered users only” can download packages
Maybe something has changed on the oracle site. "accept license agreement" was not a problem earlier.
thanks a lot. was a great help. wget couldn't get the jdk tar.gz file though. "DownThemAll"ed it. would that be due to the "accept license agreement" part?
Thanks, it works perfect!
weget is not available. try to download a jdk7 file. http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html
Thank you. It's usefull. But does to much for my case (X11 free server)
good link fo install jdk7 https://gist.github.com/1114571
God, this has saved me alot of grief. Thank you so much! I used to have a how-to like this for debian etch, and I seem to have lost it.. your site is a saver!
wheezy/sid. path had to be correct because I used Bash autocomplete as I was typing it in. anyway it was easy to fix the links manually with ln -sf /new/path/to/javac /etc/alternatives/javac
Strange. Which debian version we are talking about? I didn't have such problems with debian lenny or squeeze. Check carefully path again, wrong path maybe is not reportet by update-alternatives command.
update-alternatives didn't actually change the symlinks in /etc/alternatives for me, even though update-alternatives --config java shows the new (1.7) being automatic. I can change them by hand, but any idea why it didn't work? I got no error message once I ran the commands using sudo.
Thank you, I was in trouble with configurtion of java 7. It worked like a charm in Debian 6 Squeeze.
Agree with you about /usr/local/lib/ I wrote about 64-bit java it's true. So in a stadard conform way we to create in /usr/local/lib64/ (soft) links to /usr/local/lib/. Please correct me if i'm wrong. Src: Linux Filesystem Hierarchy.
Hello, thx for this great tutorial. I just made a little adjustment: I used /usr/local/lib/... as this is the folder for users. /usr/lib/ is for the system (aptitude). And you should differ between lib and lib64 Stefan
Get the new Java 7 Update 3 with: wget http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.tar.gz
*hugs* Worked like a charm!
Thanks man, this really helped me. ;)
Saved me some time! Thanks a lot!
You welcome Jorge! P.S. You can't be a dummy as long you are interested in java technology ;)
Thanks a lot!! I was trying to find a way how to install Java in Debian testing. Finally i could make it, all thanks to your explanation. It works perfect for dummies like me. Thanks!
Halle Mateusz, creation of good benchmark is not so simple as it may appear. There are things like HotSpot Dynamic Compilation, garbage collection and other performance and resource management of vm that shold be considered, but can't be measured 100%. I any case you have to skip the warm up Phase in your benchmark and please dont' expect to much by such benchmarks (Rule 0). You are invited to post your benchmark code here and we can try it on our self or maybe improve it. P.S. difference in 11ms is still Ok due typical System.currentTimeMillis() accuracy which is typical +- 15 ms on most OS + JVM combinations :)
Thank You very much. I installed JDK 7 and it works good. But I'm a little bit disappointed. My primary goal in installing 7 was to increase performance (I've read that it is much faster than JDK 6). But after installation I run a small benchmark (mainly memory operations: allocation, array copy and GC). I was disenchanted. JDK 7 is not faster than 6, but it appears a little bit slower :( Average from 10 runs: JDK 6: 704 [ms] JDK 7: 715 [ms] Maybe the next updates will be faster (now I use JDK 7u1).
Thank you Gonçalo Sousa. It's fixed now ;)