- Problem
- I’m using some software that relies on Sun-only code such as BASE64Decoder. I need to use the Sun Microsystems JVM (and SDK), but I couldn’t uninstall GCJ, the existing JVM.
- Solution
-
- Get the installation file from Sun’s website.
- Go to java.sun.com
- Click “J2SE 5.0” (or current version) in the Popular Downloads bar to the right.
- Click the “Download JDK 5.0” link in the second section or so (not the JRE link).
- Accept the license agreement and download the “Linux self-extracting file” to the Desktop
- Make sure you have java-package and fakeroot on your system:
- Update your respositories before installing java-package
sudo apt-get update
(or through Synaptic: Edit -> Reload Package Information)
- Install java-package
sudo apt-get install java-package
(or through Synaptic)
- Install fakeroot
sudo apt-get install fakeroot
(or through Synaptic)
- Create a Debian package:
fakeroot make-jpkg jdk-1_5_0_05-linux-i586.bin
- Install the package:
dpkg -i sun-j2sdk1.5_1.5.0+update05_i386.deb
- Create a link to the JDK (makes for an easier upgrade process – just repoint the link):
ln -s /usr/lib/j2sdk1.5-sun /usr/lib/java
- Uninstall GCJ packages to let the Sun binaries be used instead. Do a search in Synaptic for “gcj” and uninstall each of the installed items listed. Skip those that would uninstall a large list of other packages such as alien and OpenOffice. I found that the ones to skip were libgcj6 and libgcj-common.
- Set your global environment variables:
sudo gedit /etc/profile
In this file you need to replace “export PATH” with the following text:
export PATH
JAVA_HOME="/usr/lib/java"
export JAVA_HOME
CLASSPATH="$HOME/java:."
export CLASSPATH
Now you need to apply the changes:
. /etc/profile
- Verify your installation:
java -version
Also try writing a little Hello World program and running it from different directories.
- Explanation
- When you use the “java” command, the operating system will use the first instance it comes across — in my case, GCJ’s.
- Resources
- Original solution: Debian Manual has more detail and explanation, but less step-by-step instructions. It also has some post-installation tips.
Ryan Ruiz says:
Excellent instructions. Much apprciated!! Thanks. Great info on building a .deb package.
MEEPr » GCJ Makes Babies Cry says:
[...] So, after scouring the web for sometime, I found this blog post that describes a good way to install the JRE on ubuntu. http://www.brainonfire.net/blog/solutions/?p=6 [...]
Hasan says:
Hi, I was following ur instructions above, but got the following problem with step 3. Any help will be greatly appreciated. Thanks!
alhasan@alhasan-laptop:~/temp$ fakeroot make-jpkg jdk-6-linux-i586.bin Creating temporary directory: /tmp/make-jpkg.XXXXRqzfmE Loading plugins: blackdown-j2re.sh blackdown-j2sdk.sh common.sh ibm-j2re.sh ibm-j2sdk.sh j2re.sh j2sdk-doc.sh j2sdk.sh j2se.sh sun-j2re.sh sun-j2sdk-doc.sh sun-j2sdk.sh
No matching plugin was found. Removing temporary directory: done alhasan@alhasan-laptop:~/temp$
Tim McCormack says:
It looks like you might need the development version of java-package (in the feisty repository), as I found in the Ubuntu forums.