Howto Install/Setup Oracle/Sun Java 1.6.X on Ubuntu 10.10

Background

Typically Most Linux Distros (RHEL, CentOS, Fedora, and Ubuntu) come with OpenJDK by default. NOTE: OpenJDK is also referred to as Iced Tea. However OpenJDK is NOT Oracle/Sun Java. It’s the open source edition of Java and for whatever reason a lot of Java applicaions simply don’t work correctly with it. To verify which version of java you’re system is configured for simply run the command java -version.

1
2
3
4
5
6
7
% which java
/usr/bin/java
 
% java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.7) (6b20-1.9.7-0ubuntu1)
OpenJDK Server VM (build 19.0-b09, mixed mode)

If you’re using OpenJDK, here’s a quick/simple way to switch your system over to Oracle/Sun Java.

Point to Ubuntu’s “Partners Repository”

For starters lets check to see if you’ve got the partners repository set up. It doesn’t typically appear to be set up correctly when you’ve upgraded from previous versions of Ubuntu to later versions such as Maverick.

1
% sudo apt-cache search sun | grep java6

So it doesn’t look like it’s set up in the Ubuntu Software Center, otherwise you’d be seeing the sun-java6* packages. So let’s go set it up. First fire up the Software Center:

1
% sudo software-center

To add the partners repository we’re going to select the old ones (Binary & Source) for Jaunty, and repoint them to Maverick’s repos. Just follow along with the screenshots below.

Ubuntu Software Center
Software Sources
partners repository
edit source dialog pre
edit source dialog post
edit source dialog pre
edit source dialog post
mark partners repository
Oracle/Sun EULA #1
Oracle/Sun EULA #2
Oracle/Sun EULA #3

Now let’s recheck to see if we’re pointing at the partners repository.

1
2
3
4
5
6
7
8
9
% sudo apt-cache search sun | grep java6
sun-java6-source - Sun Java(TM) Development Kit (JDK) 6 source files
sun-java6-plugin - The Java(TM) Plug-in, Java SE 6
sun-java6-jre - Sun Java(TM) Runtime Environment (JRE) 6 (architecture independent files)
sun-java6-jdk - Sun Java(TM) Development Kit (JDK) 6
sun-java6-javadb - Java(TM) DB, Sun Microsystems' distribution of Apache Derby
sun-java6-fonts - Lucida TrueType fonts (from the Sun JRE)
sun-java6-demo - Sun Java(TM) Development Kit (JDK) 6 demos and examples
sun-java6-bin - Sun Java(TM) Runtime Environment (JRE) 6 (architecture dependent files)

Looks good! Now we’re set to install/configure Oracle/Sun Java.

Install Oracle/Sun Java

Run the following command to install all the java6 packages.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
% sudo apt-get install sun-java6-plugin sun-java6-jdk sun-java6-bin sun-java6-jre
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  python-evince kdesudo python-gnomedesktop python-metacity python-mediaprofiles python-bugbuddy python-totem-plparser python-evolution update-manager-kde python-gtop
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  gsfonts-x11 unixodbc
Suggested packages:
  sun-java6-demo openjdk-6-doc sun-java6-source sun-java6-fonts libmyodbc odbc-postgresql tdsodbc unixodbc-bin
The following NEW packages will be installed:
  gsfonts-x11 sun-java6-bin sun-java6-jdk sun-java6-jre sun-java6-plugin unixodbc
0 upgraded, 6 newly installed, 0 to remove and 34 not upgraded.
Need to get 56.8MB of archives.
After this operation, 167MB of additional disk space will be used.
Do you want to continue [Y/n]? Y

At this point after selecting Y to continue several screens will show up where you’ll have to agree to Oracle’s EULA[End user’s License Agreement]. You can use the down arrow key to scroll to the bottom and then hit the tab key to switch to the Ok button. Use the spacebar to select the Ok button.

Ubuntu Software Center
Software Sources
partners repository
edit source dialog pre
edit source dialog post
edit source dialog pre
edit source dialog post
mark partners repository
Oracle/Sun EULA #1
Oracle/Sun EULA #2
Oracle/Sun EULA #3

NOTE: use the left/right arrow keys and the spacebar key to hit the Yes button.

The download/install will proceed and eventually Oracle/Sun Java will be installed along with it’s browser plugins.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
....
....
# contining from above
 
Get:1 http://archive.canonical.com/ubuntu/ maverick/partner sun-java6-jre all 6.24-1build0.10.10.1 [6,386kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ maverick/main unixodbc i386 2.2.14p2-1ubuntu1 [233kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ maverick/main gsfonts-x11 all 0.21 [10.5kB]
Get:4 http://archive.canonical.com/ubuntu/ maverick/partner sun-java6-bin i386 6.24-1build0.10.10.1 [30.0MB]
Get:5 http://archive.canonical.com/ubuntu/ maverick/partner sun-java6-jdk i386 6.24-1build0.10.10.1 [20.2MB]                                                                                             
Get:6 http://archive.canonical.com/ubuntu/ maverick/partner sun-java6-plugin i386 6.24-1build0.10.10.1 [1,854B]                                                                                          
Fetched 56.8MB in 27s (2,054kB/s)                                                                                                                                                                        
Preconfiguring packages ...
Selecting previously deselected package sun-java6-jre.
(Reading database ... 183617 files and directories currently installed.)
Unpacking sun-java6-jre (from .../sun-java6-jre_6.24-1build0.10.10.1_all.deb) ...
Selecting previously deselected package unixodbc.
Unpacking unixodbc (from .../unixodbc_2.2.14p2-1ubuntu1_i386.deb) ...
Selecting previously deselected package sun-java6-bin.
Unpacking sun-java6-bin (from .../sun-java6-bin_6.24-1build0.10.10.1_i386.deb) ...
sun-dlj-v1-1 license has already been accepted
Selecting previously deselected package sun-java6-jdk.
Unpacking sun-java6-jdk (from .../sun-java6-jdk_6.24-1build0.10.10.1_i386.deb) ...
sun-dlj-v1-1 license has already been accepted
Selecting previously deselected package gsfonts-x11.
Unpacking gsfonts-x11 (from .../gsfonts-x11_0.21_all.deb) ...
Selecting previously deselected package sun-java6-plugin.
Unpacking sun-java6-plugin (from .../sun-java6-plugin_6.24-1build0.10.10.1_i386.deb) ...
Processing triggers for shared-mime-info ...
Unknown media type in type 'all/all'
 
Unknown media type in type 'all/allfiles'
 
Unknown media type in type 'uri/mms'
 
Unknown media type in type 'uri/mmst'
 
Unknown media type in type 'uri/mmsu'
 
Unknown media type in type 'uri/pnm'
 
Unknown media type in type 'uri/rtspt'
 
Unknown media type in type 'uri/rtspu'
 
Unknown media type in type 'fonts/package'
 
Unknown media type in type 'interface/x-winamp-skin'
 
Processing triggers for man-db ...
Processing triggers for python-gmenu ...
Rebuilding /usr/share/applications/desktop.en_US.utf8.cache...
Processing triggers for desktop-file-utils ...
Processing triggers for doc-base ...
Processing 1 added doc-base file(s)...
Registering documents with scrollkeeper...
Processing triggers for fontconfig ...
Processing triggers for python-support ...
Setting up unixodbc (2.2.14p2-1ubuntu1) ...
Setting up gsfonts-x11 (0.21) ...
Setting up sun-java6-bin (6.24-1build0.10.10.1) ...
update-alternatives: using /usr/lib/jvm/java-6-sun/jre/bin/ControlPanel to provide /usr/bin/ControlPanel (ControlPanel) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/jre/bin/java_vm to provide /usr/bin/java_vm (java_vm) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/jre/bin/jcontrol to provide /usr/bin/jcontrol (jcontrol) in auto mode.
Setting up sun-java6-jre (6.24-1build0.10.10.1) ...
Setting up sun-java6-jdk (6.24-1build0.10.10.1) ...
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/HtmlConverter to provide /usr/bin/HtmlConverter (HtmlConverter) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/appletviewer to provide /usr/bin/appletviewer (appletviewer) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/apt to provide /usr/bin/apt (apt) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/extcheck to provide /usr/bin/extcheck (extcheck) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/idlj to provide /usr/bin/idlj (idlj) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jar to provide /usr/bin/jar (jar) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jarsigner to provide /usr/bin/jarsigner (jarsigner) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/java-rmi.cgi to provide /usr/bin/java-rmi.cgi (java-rmi.cgi) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/javac to provide /usr/bin/javac (javac) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/javadoc to provide /usr/bin/javadoc (javadoc) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/javah to provide /usr/bin/javah (javah) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/javap to provide /usr/bin/javap (javap) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jdb to provide /usr/bin/jdb (jdb) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jhat to provide /usr/bin/jhat (jhat) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jinfo to provide /usr/bin/jinfo (jinfo) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jmap to provide /usr/bin/jmap (jmap) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jps to provide /usr/bin/jps (jps) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jrunscript to provide /usr/bin/jrunscript (jrunscript) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jsadebugd to provide /usr/bin/jsadebugd (jsadebugd) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jstack to provide /usr/bin/jstack (jstack) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jstat to provide /usr/bin/jstat (jstat) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/jstatd to provide /usr/bin/jstatd (jstatd) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/native2ascii to provide /usr/bin/native2ascii (native2ascii) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/rmic to provide /usr/bin/rmic (rmic) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/schemagen to provide /usr/bin/schemagen (schemagen) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/serialver to provide /usr/bin/serialver (serialver) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/wsgen to provide /usr/bin/wsgen (wsgen) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/wsimport to provide /usr/bin/wsimport (wsimport) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-sun/bin/xjc to provide /usr/bin/xjc (xjc) in auto mode.
Setting up sun-java6-plugin (6.24-1build0.10.10.1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

Make Oracle/Sun Java the default

1
2
3
4
5
6
7
8
# make java6 the default
% sudo update-java-alternatives -s java-6-sun 
 
# check if it worked
% java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Server VM (build 19.1-b02, mixed mode)

If all went well you should now see Oracle/Sun Java as the default in the browser too. NOTE: You can use this url to check out your browser.

Pitfalls/Troubleshooting Tips

If you happen upon a system where someone neglected to install all of the required sun-java6* packages, you may see some odd behavior where java at the command line is correct, but your web browser plugin doesn’t appear to be working correctly. If you try and run the command update-java-alternatives to reconfirm that Oracle/Sun Java is in fact the default, you’ll see messages stating that there are no alternatives for mozilla-javaplugin.so or xulrunner-1.9-javaplugin.so. Similar to this:

1
2
3
4
5
% sudo update-java-alternatives -s java-6-sun 
update-alternatives: error: no alternatives for mozilla-javaplugin.so. 
update-alternatives: error: no alternatives for xulrunner-1.9-javaplugin.so. 
update-alternatives: error: no alternatives for mozilla-javaplugin.so. 
update-alternatives: error: no alternatives for xulrunner-1.9-javaplugin.so.

Simply install the missing sun-java6-plugin* and sun-java6-fonts* packages, and rerun the update-java-alternatives command.

1
2
3
4
5
# install missing packages
% sudo apt-get install sun-java6-plugin sun-java6-fonts
 
# update alternatives
% sudo update-java-alternatives -s java-6-sun

References

This entry was posted in java, linux, package management, Syndicated, sysadmin, tip, tips & tricks, Ubuntu. Bookmark the permalink.

Comments are closed.