Ubuntu Geek

Ubuntu Linux Tips,Howtos&Tutorials|Feisty,Gutsy,Hardy,Intrepid

  • RSS Feed

    subscribe to the ubuntu Geek RSS feed


  • Sponsor

  • Categories

  • Meta

  • Sponsor

  • Archives

  • Support Ubuntugeek

    Amount $:
    Website(Optional):


  • Favourite Sites

How to Install Java Runtime Environment (JRE) in Ubuntu

Posted by admin on April 15th, 2007 Email This Post Email This Post

Java is an object-oriented programming language developed by Sun Microsystems in the early 1990s. Java applications are compiled to bytecode, which at runtime is either interpreted or compiled to native machine code for execution.

The language itself derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. JavaScript, a scripting language, shares a similar name and has similar syntax, but is not directly related to Java.

Currently Ubuntu has the following Java packages

sun-java6-bin - Contains the binaries

sun-java6-demo - Contains demos and examples

sun-java6-doc - Contains the documentation

sun-java6-fonts - Contains the Lucida TrueType fonts from the JRE

sun-java6-jdk - Contains the metapackage for the JDK

sun-java6-jre - Contains the metapackage for the JRE

sun-java6-plugin - Contains the plug-in for Mozilla-based browsers

sun-java6-source - Contains source files for the JDK

Installing the Java Runtime Environment

First you need to check multiverse repository enabled or not after that open a terminal window. Since you are going to be installing the JRE and the web browser plug-in, you’ll be using the following command from a terminal

sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

Once it downloads the packages and begins the installation, you’ll get a screen that contains the Sun Operating System Distributor License for Java and hit Enter to continue. You’ll see a dialog that asks you if you agree with the DLJ license terms. Select Yes, and hit Enter; the JRE will finish installing.

Testing Java Runtime Environment

You’ll want to confirm that your system is configured properly for Sun’s JRE. This is a two-step process.

First, check that the JRE is properly installed by running the following command from a terminal.

java -version

You should get similar output

java version “1.6.0″
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
Testing Java Plugin for Firefox

open Firefox and typing about:plugins in the address bar and check for java plugin

Share/Save/Bookmark

If you want to be notified the next time we write something please subscribe to our RSS feed.Thanks for Visiting!

Related Articles

75 Responses to “How to Install Java Runtime Environment (JRE) in Ubuntu”

  1. OliBlogger Says:

    That’s odd.
    When you installed sun-java6-* I do not expect java -version to give
    Java version “1.5.0_08″
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)

    but more something like
    java version "1.6.0_01"
    Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
    Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

    I do have a question though: Is Java 6 or Java 6U1 (6 update 1) installed?

  2. admin Says:

    thank you OliBlogger i have updated the correct ouput and java6 only not java6u1

  3. samol Says:

    It’s 3″30 and i just installed sun-java6-.
    When I run java -version I get:

    java version “1.4.2-02″
    Java(TM) 2 Runtime Environment, Standard Edition (build Blackdown-1.4.2-02)
    Java HotSpot(TM) Client VM (build Blackdown-1.4.2-02, mixed mode)

    Should I not get Java version “1.6.0″

    thanks

  4. Martin Says:

    Yes, but you have to set Sun’s Java as default java.

  5. samol Says:

    Got it. thank you.

  6. sunny Says:

    when i configure jre on my ubuntu, a blue print is shown ,something like sun license,but no any more response.i don’t know why?
    then i type
    sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts
    in a new terminal,there is:
    E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

  7. admin Says:

    @sunny

    you are running another apt-get process you can check this using

    ps -ef

    look for apt-get process number and kill the process using the following command

    kill -9 processid

  8. Jay A. Babcock Says:

    OK - here’s what I had to do.Put:

    sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

    into terminal and it stalled when I got a blue screen. Then I went to Synpatics Package Manager where I got a message about a broken package, it had instructions on what to do from the terminal, did that

    Ran the terminal command again adn this time it went through. Then ran it a third time to get the browser plug-in.

  9. Jay A. Babcock Says:

    EDIT
    after using dpkg –configure -a
    I restarted Synaptics and found JRE in the Installed (upgradable) section and that worked to install (clicked Apply)

    I now had the JRE updated, but stil no browser plug-in, so I ran
    sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

    a second time and it installed the plug-in

  10. sid Says:

    im a serious noob at this stuff so bare with me

    when im in the terminal and i type in

    sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

    i get

    sun-java6-fonts
    Reading package lists… Done
    Building dependency tree… Done
    E: Couldn’t find package sun-java6-jre

    any1 know whats up?

  11. admin Says:

    you need to make sure you have enables universe,multiverse repositories in your /etc/apt/sources.list file

  12. sid Says:

    ahh ok changed and works!

    thanks admin

  13. Anthony Says:

    I have the version 1.6.0 loaded, how do I get the update? I am trying to work a Ubuntu 7.04 machine for my wife, she wants to play on the Pogo website and it’s a no go. It says I need the most current version of Java runtime.

  14. Arun Kumar Says:

    Like others, I am getting stuck with the blue screen showing the Sun Java license agreement. I have no idea how to “accept” this license: there doesn’t seem to be any button to click, and I have tried the Return, Y (for Yes), O (for OK) and spacebar but there doesn’t seem to be any way to close the dialog and continue with the installation. Any tips would be appreciated (I am clueless about what I am doing!)

    P.S. to make things a little more complicated, I am running Ubuntu as a virtual OK on my Mac Book Pro using Parallels!

  15. Arun Kumar Says:

    Problem went away by itself… The software update feature in Ubuntu kicked in and gave me Java 1.6!

  16. Jørgen Says:

    I did as instructed but nothing happened when i pushed “enter” in the bluescreen. I then closed the window and ran the command again but then got the following message: E: dpkg was interrupted, you must manually run ‘dpkg –configure -a’ to correct the problem.

    Anyone know what went wrong and what i can do to fix this?

  17. Jørgen Says:

    I actually got the same error message when i tried to open Synaptic package manager too, making it impossible to run. Hope someone can help me with this, i’m a linux noob… :(

  18. Jørgen Says:

    nevermind, was a bit to hasty… :)

  19. Ahmed Ragab Says:

    I just got the license agreement blue screen without any input key. But when I restarted the installer apt-get requesting to install j2sdk package, I managed to accept the license of j2sdk by a message box with yes / no buttons. but now I am stuck at the java6 license agreement which does not include an action button to accept the license. Any one have an idea about how to solve this problem

  20. Ahmed Nabhan Says:

    A strange thing happened now. when I used the down arrow key until it sets the focus on and pressed Enter, it shows up a yes/no message box through which I was able to accept license of java6

  21. Keith S-C Says:

    I had the same problem. I scrolled all the way to the bottom and then clicked on TAB to get the button to be highlighted. This took me a long time to figure out!

  22. harry Says:

    Oops my Java comments should have been Here.
    I have Ubuntu 6.06 now and went to Sun’website to download java for Linux….curiously they appear to do versions for RedHat and others, but not Ubuntu.
    I can’t get my head round repositories and other stuff…perhaps I should have looked there first and then done what was shown in #10,#11′#12 (above). Clearly, I still need a step-by-step guide.

    In the past I’ve groaned about .PDF’s - but now 6.06 reads them!
    Ah, printers next….after JAVA, which I need for streaming prices on websites I visit. Curiously under Win98SE/IE5 the latest Java messes up, so I have to block it and resume with the earlier version that came bundled…..I don’t understand……what is Java and how does it run under another OS? Probably best to stay ignorant…..but I’d like to have the streaming prices under Firefox.
    Bye.

  23. frustrated noob Says:

    I had the same problem as someone else. I also recieved the message telling me the sun-java6-jre couldnt be found. I noticed there was a response, and I had done what the person said. I still seem to be getting the same error….I’m not even sure what version of ubuntu i have, If anyone could help me figure out what I’m missing I’d really apprciate it.

  24. Grog Says:

    Well this worked great for me…

    However, I was wondering how I might go about installing Java 6 Update 2? There is a security fix in it I’d like to have.

    Similar method?

  25. Duane Says:

    Hi,

    Use the down arrow until you reach the bottom, then use the tab key to move the cursor to highlight the OK, then hit enter, do the same on the next screen that pop ups up too, should work fine every time. This is often standard for these types of installs…

    Hope this helps!

    Duane

  26. Kaikai Says:

    Hi for the blue screen I found how to fix it.

    I closed the terminal, launched another terminal and typed “dpkg –configure -a”

  27. Kaikai Says:

    Hi

    In fact you should install it through Synaptic Package Manager. It will allow you to installl it

  28. Tom J Says:

    Frist, you have to close Firefox, or it won’t work.

    Then, I got this message: Use of uninitialized value in print at /var/lib/defoma/scripts/gs.defoma line 108

  29. Les Says:

    For people have problems with their java coming up with an old version after you install the new 1.6, do the following from a root shell:

    > update-java-alternatives -s java-6-sun

    This will change the Java engine over to the new version.

    You can check the installed version or change with:

    > update-java-alternatives -l

    ..which will give you output similar to:

    java-6-sun 63 /usr/lib/jvm/java-6-sun
    java-gcj 1041 /usr/lib/jvm/java-gcj

  30. ice Says:

    Thnx Les! My java also pointed to the old version, but not anymore :)

  31. Clevermonkey Says:

    Yes, Les, thanks for that. Just what I needed too.

  32. Helen Says:

    I have followed the above instructions and Java was installed no problem. When I go to yahoo games it says I don’t have java. What am I doing wrong?

    Thanks
    Helen

  33. admin Says:

    try to run the following command in your firefox

    about:plugins

    and check java plugin is showing or not

  34. Helen Says:

    Hi
    Yes the java plugin is showing

  35. Jorge Millares-Bobet Says:

    when i do it(pasted sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts) it said that the installer sun-java6-jre can not be found, what should i do =S
    please help me

  36. Jorge Millares-Bobet Says:

    also i tried the
    /etc/apt/sources.list file
    and it said

    /etc/apt/sources.list file
    bash: /etc/apt/sources.list: Permission denied

  37. Prast Says:

    Help me please, I’m totally nob.

    I try to run “about:plugins” in my firefox but java plugin is not showing

    Thanks before.

  38. dave Says:

    @prast

    try this

    Check your java version.

    java -version

    In my case is the last one from the Ubuntu repo:
    1.6.0_05

    Configure java with the following command

    sudo update-alternatives --config java

    Now go to /usr/lib/jvm/java-6-sun/jre/bin/java

    Run the following command from terminal

    sudo sed -i ’s/XINERAMA/FAKEEXTN/g’ /usr/lib/jvm/java-6-sun-1.6.0.05/jre/lib/i386/xawt/libmawt.so

    Delete all links

    sudo rm -r /usr/lib/firefox/plugins/libjava*

    sudo rm -r /usr/lib/firefox-plugins/plugins/libjava*

    sudo rm -r /usr/lib/firefox-3.0b3/plugins/libjava*

    Reconfigure alternatives

    sudo update-alternatives --all

    Leave everything as default except for

    rmiregistry
    java
    keytool
    rmid
    orbd

    All of these entries must have /usr/lib/jvm/java-6-sun/jre/bin/ as alternative

    From the terminal refresh java shortcuts

    sudo update-java-alternatives -s $(update-java-alternatives -l | cut -d’ ‘ -f1)

    Then re-create java shortcuts for Firefox(es):

    sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.05/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/firefox/plugins/

    sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.05/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/firefox-plugins/plugins/

    sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.05/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/firefox-3.0b3/plugins/

    Now open Firefox, type about : plugins in the address bar and java should be there

  39. Weez Says:

    Hi,

    To accept the license, I click on F12.

    I have ubuntu feisty fawn installed with current updates. I used your terminal command which installed the .deb file. I can use java in both Firefox and my default browser Swiftweasel. But,

    When I type in java -version, I get the following:

    The program ;java’ can be found in the following packages:
    jsrel.4, gij-4.1, kaffe, jamvm java-gcj-compat, cacao, sablevm,
    bash: java: command not found.
    When I do a search for ‘java’ file in system, I have links (broken) in the following for /etc/alternatives, for java, javaws,javaws.1.gz java_vm. And links (broken) in /usr/bin for javaws, java, java_vm, and link (broken) in /usr/share/man/man1 for javaws.1.gz and java.1.gz

  40. Clay77 Says:

    Hi,

    I can’t seem to get firefox to recognize Java. I’ve installed the plugin and tried your instructions above, but when I make the sym link it comes up as a broken link…any ideas why that’s happening?

    Many thanks!

  41. gh423 Says:

    I also could not get firefox to use sun-java. I tried a lot of ideas from forums, etc. It finally started to work after running:

    sudo update-alternatives –config xulrunner-1.9-javaplugin.so

    and selecting the line for sun java. This was using sun-java6.

    I found this by running “update-alternatives -all” and selecting everything that looked like sun java. The above was the only one that I found that had not already be set to a sun java with –config java” and “–config jre”

  42. rams k. Says:

    Can anyone please tell me how to install JRE for IE in ubuntu?
    Thank you…

  43. Auron Says:

    look im trying to run runscape for 3 months so pls if u have a guide pls tell me thank u

  44. Nadeem Says:

    If some one is stuck at license page. He should follow these steps.
    1- Press the tab key, control will go at
    2- Then press enter key

  45. Tim Silver Says:

    Ubuntu 8.04

    Guide worked absolutely fine for me - but I’m glad I read the bit about using the arrow down key and tab key on the licence page.

  46. xirius Says:

    I’m Mr. “no idea of installation”
    i,m also a noob in this kind of situation and i think this problem would be very simple to answer….

    when i started to open the package it says:
    “dependecies not satisfiable” then a name of an anther software next to it(e.g. jdk bla bla bla)…
    what will i do

  47. xirius Says:

    ca n u guys help me???

  48. David Turner Says:

    I just installed Ubuntu. Never used anyother opperating system before. I can see why. The last time I had trouble installing stuff was back in Win 95 days. However I will persist and learn. Just wish it was easier to install stuff.

  49. Casey Says:

    Gh423 in comment 41 had the final key for me as well. I’m running hardy and firefox 3. There is a test applet for seeing your results.

    Thanks everyone.

  50. zack Says:

    I just started using linux for the first time today and im loving its versatility, but i really dont know how to install anything i know i probably shouldn’t be posting here, but you guys seem to really know the OS so i was wondering if you could point me towards a site that could teach me all the stuff i need to know to use Ubuntu properly.

  51. Nakul Says:

    Can anyone help with this.someone else also posted the similar one but i didnt find any solution to it.

    The program ‘java’ can be found in the following packages:
    * java-gcj-compat-headless
    * openjdk-6-jre-headless
    * j2re1.4
    * kaffe
    * cacao
    * gij-4.1
    * jamvm
    * gij-4.2
    * sablevm
    Try: sudo apt-get install
    bash: java: command not found

    i dont know how to add the java javac and commands like this to run in terminal. Thanks

  52. wikidkaka Says:

    #51: if you are using ubuntu just run the following in the given order

    $ sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
    $ sudo update-java-alternatives -s java-6-sun
    and then add the line below at the start of /etc/jvm file
    /usr/lib/jvm/java-6-sun

    the commands should work for other distros too. But am not sure if they come with an update-java-alternatives utility

  53. someone help meeeeeeeeee! Says:

    hey everyone
    i only want to download javaaaaaaa!
    any kind the 6 or the 5 or w/e just need some help cuz when i download it.. it doesnt do anything!!!
    is it my internet or something!?

  54. Ben Says:

    #52: THANK YOU! That “sudo update-java-alternatives -s java-6-sun” totally fixed my CLI java.

  55. Gary E. Says:

    OMG…How simple was that!

    Keith S-C
    “I had the same problem. I scrolled all the way to the bottom and then clicked on TAB to get the button to be highlighted. This took me a long time to figure out!”

    Me To… Oh Brother!

    Thanks Keith for the input. I was hitting everything on the keyboard that had to do with the term.
    Boy do I feel like a dummy. :(

  56. Gary E. Says:

    By the way all of this to look at the radar maps on the National Weather Service’s site nws.noaa.gov or
    http://radar.weather.gov/Conus/index_loop.php

    We are in our hurricane season now in Florida an I rather be seeing a Java based moving image then a static one.

  57. Goofus P. Charlton Says:

    This was about the most trouble free install guide for Java that I’ve found. It went without a hitch.

  58. Robert Howard Says:

    I am trying to install java 1.6 downloaded from Sun. Following their directions on how to install it, I keep getting “no such file or directory”. can one of you please help out a newby?
    Thanks

  59. freax Says:

    @ 58: I’m newby too and got it working through this link: http://openjdk.java.net/install/

    For me, this worked fine, after I first followed the steps of comment #52, but could not save changes to ‘/etc/jvm file’
    (and it seems that’s a necessity to get it working)

    Well, then I just followed the steps here: http://openjdk.java.net/install/

    et voila, all works fine now. good luck

  60. hamid Says:

    hay guys,
    I am trying install Java Runtime Environment JRE.. this the commmand i use … sudo apt-get install sun-java6-jre.. this what i get
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Couldn’t find package san-java5-jre
    does any1 got any idea whats that mean..

  61. admin Says:

    If you want to install java5 use the following command

    error :- E: Couldn’t find package san-java5-jre

    package name sun-java5-jre not san-java5-jre

    sudo aptitude install sun-java5-jre

    If you want to install java6 use the following command

    sudo aptitude install sun-java6-jre

  62. achmat Says:

    when entering
    ./jre-1_5_0_08-linux-i586-rpm.bin
    in my bash script
    what can i add to it to accept the licencing agreement
    it must be in the bash script to enter yes.

    thanks

  63. Jhon F. Ortiz O. Says:

    Hi! Thanks for this information. It’s useful. Bye!

  64. statmonkey Says:

    Worked like a charm, thanks for this

  65. John Says:

    Ubuntu gurus help. I tried running java runtime environment on my laptap (fujitsu lifebook A series) and all seemed to go well until I get the screen that said to select ‘yes’ which I screwed up and closed the screen because I didn’t think it responded.

    I tried running “dpkg –configure -a” and I get this:

    dpkg: need an action option

    What am I doing wrong? Please help.

  66. John Says:

    oops, i forgot to add…i am using ubuntu 8.04

  67. newbie Says:

    Thanks, guys! I got my java working again.

    I’m on Hardy and had Open JRE which was broken. All I got was a grey box at java.com’s java test.

    I tried the installing as according to the initial instructions at the top of the page but only the missing files were added.

    But the java test still did not work.

    Then I followed Les’ advice on message 39 and did the update for java.

    Now java works fine for me now ;)

  68. newbie Says:

    Opps…Les’ message is at message 29, not 39.

  69. spy mag Says:

    Hello every1,

    8,10 beta version

    when i type the command sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts i get the following message:

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    sun-java6-jre is already the newest version.
    sun-java6-jre set to manually installed.
    Package sun-java6-plugin is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    E: Package sun-java6-plugin has no installation candidate

    universe and multiverse repositories are enabled.

    I have installed the newest java version from the synaptic,but still i cant see the plug in at firefox and i cant run some application that need java,

    P.S.i am new to linux ,
    thanks

  70. admin Says:

    @Spy Mag

    You need to make sure you have multiverse repositories are enabled in Ubuntu Intrepid

  71. Arthur Says:

    after I run command sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

    E: dpkg was interrupted, you must manually run ‘dpkg –configure -a’ to correct the problem.
    What`s the problems?

  72. Arthur Says:

    And after I runed Synaptic manager this message showed:

    E: dpkg was interrupted, you must manually run ‘dpkg –configure -a’ to correct the problem.
    E: _cache->open() failed, please report.

    what can I do with this problem?

  73. Vic Says:

    Thanksssss Wikidkaka workksssssssssssssssssssssssssssssssss!

  74. mike Says:

    it says
    E: Package sun-java6-plugin has no installation candidate
    can u please help

  75. admin Says:

    @Mike

    Make sure you have universe and multiverse repositories in your source list

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>