The Source for Java Technology Collaboration
User: Password:



Fabrizio Giudici

Fabrizio Giudici's Blog

Java with apt-get, what's the scoop?

Posted by fabriziogiudici on April 24, 2007 at 01:59 AM | Comments (4)

So the big news of the previous week was the availability of Java packages with the latest Ubuntu 7.04 (Faisty Fawn). I won't repeat what others already said, but now you can install Sun Java implementations with the standard Ubuntu tools for application maintenance (apt-get, Synaptic package manager, etc...).

It took a bit for me to upgrade my computers. The triple-boot Mac-Mini was successfully updated from Dapper to Edgy, but at this point the updater gets stuck. Two old true Intel PCs were successfully updated, but with some troubles (mainly related to the lack of disk space on the /boot partition and such). My MacBook Pro, that already started with Edgy, was updated fine - too bad that Faisty Fawn screwed up my WiFi configuration and now generates spurious mouse click events (this is very annoying since it's continuously screwing up my text as I'm typing - but it's anything that can't be fixed later, probably by installing a specific driver).

In the end, I've done it. So what? All this fatigue just for the pleasure of installing the JDK with apt-get instead of downloading the tar and extracting it?

For developers this could change just a bit. For deploying your Java applications this is an important step forward.

For instance, I've quickly packaged blueMarine as a .deb distribution (beware: it's just a first try, there are still details to refine). Packaging a .deb distribution just means to reproduce on a working folder the final layout of files (for instance I choose to place all the blueMarine stuff under /usr/local/blueMarine and the launcher under /usr/bin/blueMarine), adding a "control" file such as the following:

Section: non-free/net
Priority: extra
Maintainer: Tidalwave s.a.s. 
Package: blueMarine
Version: 0.9.EA9SNAPSHOT.1738
Installed-size: 12345678
Architecture: all
Depends: sun-java5-jre (>= 1.5.0) 
Provides: blueMarine
Description: open source application for the photographic workflow

and running a special command:

sudo dpkg -b work/ blueMarine_0.9.EA9SNAPSHOT.1738_all.deb

To install the application you just need to do:

sudo dpkg -i blueMarine_0.9.EA9SNAPSHOT.1738_all.deb

Now, to me there are two important points.

First, in the control file I could declare an explicit dependency on the Sun Java JRE distribution. This means if I try to install my application in a system where Sun JRE has not been installed, I get the following error messages and the user is notified about the required missing packages:

fritz@Scirocco:~/Desktop$ dpkg -i blueMarine_0.9.EA9SNAPSHOT.1738_all.deb 
dpkg: requested operation requires superuser privilege
fritz@Scirocco:~/Desktop$ sudo dpkg -i blueMarine_0.9.EA9SNAPSHOT.1738_all.deb 
Password:
Selecting previously deselected package bluemarine.
(Reading database ... 107651 files and directories currently installed.)
Unpacking bluemarine (from blueMarine_0.9.EA9SNAPSHOT.1738_all.deb) ...
dpkg: dependency problems prevent configuration of bluemarine:
 bluemarine depends on sun-java5-jre (>= 1.5.0); however:
  Package sun-java5-jre is not installed.
dpkg: error processing bluemarine (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 bluemarine

Second, as the .deb-packaged JRE is installed in a well-known directory (e.g. /usr/lib/jvm/jre-1.5.0-sun), I could explicitly point to it in the launcher script of blueMarine:

#!/bin/sh

export JAVA_HOME=/usr/lib/jvm/jre-1.5.0-sun
...
$JAVA_HOME/bin/java -cp ...

In this way there's no more the risk of having my application launched with the GNU's Java Virtual Machine, a thing that causes sure troubles since it's not truly compatible with Java, but unfortunately advertises itself as Java, so usually people complains with my application rather than with the distro. Of course, I can also be sure that my application will be now launched with the proper JRE version. And I'm not forced to fix these troubles by bundling yet another JRE with my application, thus creating a possible proliferation of JREs in the user's disk.

After the Sun JRE is installed, the blueMarine launcher is in the path and can be just typed from a console to run the application. So now blueMarine is a first-class citizen in Ubuntu!

Not everything has been fixed yet, and this post is just introductory. I plan to write a more extensive description within a few days, when everything is complete (and the process of creating the distribution has been possibly automated); also I'd like to understand whether it's possible to have blueMarine appear in the system menus etc.

In the meantime, feel free to ask questions or to add some points if you're expert at creating Debian packages.

PS1 I already have a question: what happens with other Linux distributions? Are they all compatible with .deb?

PS2 I've uploaded the blueMarine_0.9.EA9SNAPSHOT.1738_all.deb for trying, just remember that it's an untested snapshot, I mean I don't guarantee does something clever after the installation ;-)


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • See my response

    Posted by: robogeek on April 24, 2007 at 01:59 PM

  • Setting SUN Java 6.0 as default in Ubuntu:
    http://jroller.com/page/somatik?entry=java_6_0_on_ubuntu

    Posted by: francisdb on April 25, 2007 at 01:36 AM

  • I see one fundamental problem with packing Java applications as .deb installation packages:

    You introduce platform specifics.

    One of the (broken) promises of Java applications is platform independence. Here you follow the IMHO wrong direction of creating more platform dependencies, following the unholly lead of many Windows-only Java applications. Many of these applications might not depend on Windows at all, but because they are wrapped in a Windows-specific installer they can't be installed anywhere else. Same with .deb packages (ignoring the fact that one can painfully extract the contents from a .deb package manually).

    I don't like this trend, because it forces application providers to provide a plethora of different, incompatible installation packages for one and the same application. One for each platform. Instead I would like to see a universal Java installation format. E.g. the enhancement of Web Start into a non-nonsense installation tool. A tool which of course properly interacts with the platform specific installer/package management system. E.g. to get a Java application registered with the local package management system.

    To answer your question in the first PS: No, they are not (however, often they can be convinced to take a .deb package, too). But you see my point now?

    Posted by: twe on April 25, 2007 at 04:53 AM

  • twe, interesting point. I agree partially with you, and most notably with the JWS approach that - once some issues are fixed - should become a viable, unified way to install stuff (but not the only one, since not everybody would like it).

    I don't agree on the point of having a "unique installer", besides JWS. This is not because of technological issues (e.g. if you use stuff such as InstallAnywhere or IzPack you have an universal installer), but because installation _is_ a different thing on different platforms. For instance, on Mac OS X people prefer (and Apple advices on) "drag-n-drop" installation, which means that you get a disk image (.dmg), mount it, the application just appears as a single icon, you just drag it and drop in the "Applications" folder and it works from there.

    In a similar fashion, as I provided pre-releases of my application packed with IzPack also for Linux, I had some feedbacks of people asking for a .deb or a .rpm... So it's a user expectation constraint, I'd say, and I see no alternative here.

    Posted by: fabriziogiudici on April 25, 2007 at 05:14 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds