Search code examples
debianpackaging

Launch with Java 7 in Debian package


I've created a Debian package for my application that depends on openjdk-7-jre, problem is I also need to ensure it's launched with Java 7 (chances are Java 6 is still the default.) At present I have

Exec=java -jar Application.jar

...which will obviously just take the default Java install. I could specify something like:

Exec=/usr/lib/jvm/java-1.7.0-openjdk-i386/bin/java -jar Application.jar

...but I'm a bit weary because the architecture (i386) bit is in there, and if that changes then presumably the path wouldn't work.

Any ideas? Or am I trying to accomplish this the wrong way? Or will the above approach work after all?

I can't check in the Java code itself since obviously it won't run if it's the wrong version so can't check anything!


Solution

  • You could try to parse the output of

    /usr/bin/update-alternatives --query java
    

    in a postinst hook and rewrite your desktop file accordingly. Still dirty, but slightly better.