Muffinresearch Labs by Stuart Colville

Ubuntu: Changing the default java binary | 0 Comments

Posted in Code, Linux/Unix on 5th December 2009, 3:03 pm by

Since upgrading to Karmic I’ve had a weird issue with Charles Proxy in that the windows for settings like rewrites seemed to get completely screwed up making it very difficult to see the boxes for entering information. Here’s a screenshot of what it looks like broken.

Karl von Randow the author of Charles was looking into the issue following my bug report and after he’d been unable to reproduce the issue in a fresh install of Ubuntu Karmic with a Java Runtime downloaded from the sun site he suggested I do the same, as I was currently showing that I was running the OpenJDK java runtime.

This prompted me to do a little more digging as I prefer to only use packaged software where possible mainly for the big benefit of getting security and other updates as soon as they are made available.

On my system I had both the sun-java6-jre package as well as the openjdk-6-jre package installed.

To check which one you are using run the following command from the terminal:

$ java -version
java version "1.6.0_0"
OpenJDK Runtime Environment (IcedTea6 1.6.1) (6b16-1.6.1-3ubuntu1)
OpenJDK Server VM (build 14.0-b16, mixed mode)

To fix the problem I used the following command to switch to the SUN java binary.

sudo update-alternatives --config java
# Enter password #
There are 2 choices for the alternative java (providing /usr/bin/java).

 Selection    Path                                      Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
 1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
 2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode

Selecting 2 and hit enter and now the version is as expected.

$ java -version
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) Server VM (build 14.1-b02, mixed mode)

Running Charles again the windows that were broken now display correctly.

Post Tools

GNU screen: open tab in current working directory|(1)

A nice trick for having screen open a new tab in the same directory as the one you’re currently in. To use it add it to your .screenrc

# Open new window in current dir.
bind c stuff "screen -X chdir \$PWD;screen^M"
bind ^c stuff "screen -X chdir \$PWD;screen^M"

Hat tip: mteckert on SuperUser.com

Ubuntu: add-apt-repository: command not found|(3)

When you’re using a minimal Ubuntu install if you find the ‘add-apt-repository’ command is missing (it’s useful for adding PPAs and other repositories), then simply run:

sudo apt-get install python-software-properties

Photos on Flickr

© Copyright 2004-12 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by Slicehost.com This page was baked in 0.553s.