Category Archives: Uncategorized

Installing a new JDK in Debian/Ubuntu

I like (need) to have several JDKs installed on my system and I use Debian’s alternatives mechanism to switch easily between them. It’s just a clever use of symlinks. A nice aspect of the alternatives system is the possibility to connect “slaves”: links to other files which should be changed when their master changes. Since the JDK is made up of quite a few commands, here is what I use when I add a new version to my system:

sudo update-alternatives --install /usr/bin/java java $1/bin/java 200 \
--slave /usr/bin/jar jar $1/bin/jar \
--slave /usr/bin/jarsigner jarsigner $1/bin/jarsigner \
--slave /usr/bin/javac javac $1/bin/javac \
--slave /usr/bin/javadoc javadoc $1/bin/javadoc \
--slave /usr/bin/javah javah $1/bin/javah \
--slave /usr/bin/javap javap $1/bin/javap \
--slave /usr/bin/javaws javaws $1/bin/javaws

Then I just invoke the following command to select the JDK I want to use:

sudo update-alternatives --config java

I get presented with the following

There are 5 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status ------------------------------------------------------------   0            /usr/lib/jvm/ibm-java-x86_64-60/bin/java         200       auto mode   1            /usr/lib/jvm/ibm-java-x86_64-60/bin/java         200       manual mode   2            /usr/lib/jvm/ibm-java-x86_64-70/bin/java         200       manual mode   3            /usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/java   200       manual mode   4            /usr/lib/jvm/jdk1.6.0_31/bin/java                200       manual mode * 5            /usr/lib/jvm/jdk1.7.0_03/bin/java                200       manual mode
Press enter to keep the current choice[*], or type selection number:

And when you need to dynamically set JAVA_HOME to the appropriate path, use the following command:

export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
Share

Cassandra Connection Pool 0.7.1

I have released version 0.7.1 of my Cassandra Connection Pool. Versions in the 0.7.x series match Cassandra 0.7.x, and therefore require libthrift 0.5.
This version is also being used in the recently released Infinispan 5.0.0.CR1.
The artifacts are now available in Maven Central so you just need to add the following dependency to your pom.xml without any additional bits and pieces:

<dependency>
	<groupId>net.dataforte.cassandra</groupId>
	<artifactId>cassandra-connection-pool</artifactId>
	<version>0.7.1</version>
</dependency>

I also wish to announce that I am currently working on Cassandra Armeria, an abstraction layer for Cassandra’s ever-changing Thrift API, and hope that this will provide the basis for Infinispan’s Cassandra support in the next release cycle (5.1.0).

Share

Mirroring multiple Eclipse update sites

When you have lots of developers needing a homogeneous set of Eclipse plugins, it makes sense to provide a local mirror of the necessary update sites for easy provisioning. I have written a simple shell script for this which I put in crontab for periodic execution:
Dirty Code


#!/bin/sh
ECLIPSE_HOME=/opt/eclipse
REPO_HOME=/var/www/p2repo
JAVA_OPTS="-Dhttp.proxyHost=proxy.acme.com -Dhttp.proxyPort=3128"
UPDATE_SITES="http://download.jboss.org/jbosstools/updates/development/ http://subclipse.tigris.org/update_1.6.x/ http://m2eclipse.sonatype.org/sites/m2e http://m2eclipse.sonatype.org/sites/m2e-extras http://directory.apache.org/studio/update/1.x/ http://eclipse.jcraft.com/ http://java.decompiler.free.fr/jd-eclipse/update"
for i in $UPDATE_SITES; do
        echo $i
        java $JAVA_OPTS -jar $ECLIPSE_HOME/plugins/org.eclipse.equinox.launcher_*.jar -application org.eclipse.update.core.standaloneUpdate -command mirror -from $i -to $REPO_HOME
done
Share

Infinispan Cassandra CacheStore

Since my previous post about the Cassandra Connection Pool, I have been progressing on another project: a Cassandra CacheStore for Infinispan.
I have published on my personal SVN repository the initial source for this CacheStore, get it at:

http://dataforte.dyndns.org/svn/dataforte/infinispan-cachestore-cassandra/trunk/

If you use Maven, add my repository to your settings.xml or to your repository manager (Nexus, Artifactory, etc):

http://www.dataforte.net/listing/maven/releases/

which contains all required dependencies.

See the tests available under src/test for examples on how to setup an Infinispan cache backed up to a Cassandra database and how a Lucene InfinispanDirectory can take advantage of both systems.

I am working on rearranging things for potential inclusion in the main Infinispan package, so some things may change (package names). Also key expiration is not as efficient as I would like, but release early, release often is good practice, so there 🙂

Share

Cassandra Connection Pool

For a project of mine I’ve had need for a robust, decent connection pool for Cassandra. Since I use the thrift APIs directly without other layers, I decided to use Tomcat 7’s excellent jdbc-pool as a base. The result is my cassandra-connection-pool which at the moment may be fetched from my github repository at http://github.com/tristantarrant/cassandra-connection-pool
It supports most of the features of its parent implementation: connection validation on creation, release and idle, abandoned connection detection, etc.
Let me know if you use it.

Share

Too-OneBee

I have started yet another open-source project: Too-OneBee. It’s both an embeddable and standalone web console for monitoring a J2EE application. It lives at Google Code: http://code.google.com/p/too-onebee/
It embeds a javax.scripting console for running scripts within the webapp, a JMX browser, a session/request/application/server context viewer, a JNDI browser.
I would like to add pluggable handlers so that, for example, one could add Spring integration, a JDBC tool (a la phpMyAdmin), etc.

Too-One Bee - Scripting
Too-One Bee - Scripting
Share

Firefox 3.6 and Thunderbird 3.0 on Karmic

I regularly use Thunderbird 3.0 betas on my Karmic via the Ubuntu Daily Mozilla PPA. Unfortunately the PPA also contains snapshot builds of Firefox 3.5 and XulRunner 1.9.1, which I want to keep at their standard Ubuntu versions. To make apt-get upgradeing as painless as possible I am using package pinning to stop unwanted packages from other repositories to override the defaults.

I have added this to my /etc/apt/preferences file:
Dirty Code

Package: *
Pin: release o=Ubuntu,a=karmic
Pin-Priority: 900

Package: firefox-3.5
Pin: release o=LP-PPA-ubuntu-mozilla-daily,a=karmic
Pin-Priority: -10

Package: firefox-3.5-branding
Pin: release o=LP-PPA-ubuntu-mozilla-daily,a=karmic
Pin-Priority: -10

Package: firefox-3.5-gnome-support
Pin: release o=LP-PPA-ubuntu-mozilla-daily,a=karmic
Pin-Priority: -10

Package: firefox
Pin: release o=LP-PPA-ubuntu-mozilla-daily,a=karmic
Pin-Priority: -10

Package: firefox-gnome-support
Pin: release o=LP-PPA-ubuntu-mozilla-daily,a=karmic
Pin-Priority: -10

Package: xulrunner-1.9.1
Pin: release o=LP-PPA-ubuntu-mozilla-daily,a=karmic
Pin-Priority: -10

Package: xulrunner-1.9.1-gnome-support
Pin: release o=LP-PPA-ubuntu-mozilla-daily,a=karmic
Pin-Priority: -10
Share

Eclipse 3.6, x86_64 and Gnome proxy support

I recently took the plunge back into 64-bit Ubuntu after I originally ditched it two and a half years ago mostly because of desktop Java stuff. I am now using Eclipse 3.6M2 so that compatibility with GTK+ 2.18 is good, but I’ve encountered a problem with native proxy support: my proxy settings were completely ignored from within Eclipse. I have contributed a (very simple) patch to Eclipse’s Bugzilla and it will hopefully appear in Eclipse 3.6M4.

Share