[Reopened] [Dapper] Eclipse startup script should respect jwm setting via update-alternatives

Bug #36534 reported by Erich Pawlik
30
Affects Status Importance Assigned to Milestone
eclipse (Debian)
Fix Released
Unknown
eclipse (Ubuntu)
Fix Released
Medium
Niels Thykier

Bug Description

[Dapper] eclipse 3.1.1-8ubuntu2

I have changed by default jvm to sun java 1.5 via the update-alternatives mechanism (using the package provided in the Dapper repositories).

The eclipse startup script is ignoring this setting even after I did change the default jvm inside eclipse. It cycles through the entries in /etc/eclipse/java_home and picks the first one that happens to be gij.

Of cause there are several ways to work around this such as using the -vm option. But I feel that eclipse should be good Debian citizen.

The bug has been rejected with the argument that update-alternatives is not able to handle JAVA_HOME. This argument is not very convincing. Basically the bug could be fixed by adapting the heuristics used in the eclipse startup script to determine $JAVA_HOME.

Because I am not very familiar with shell scripting and don't know anything about the Debian packing system, I don't attempt a fix. However the basic strategy to fix the issue could be to determine the jvm from update-alternatives and put the line for the right jvm at the beginning of /etc/eclipse/java_home before handing over /etc/eclipse/java_home to the command to determine javahomelist.

To prove the feasibility of my approach: The following (I admit a bit clumpsy) script writes the required variant of /etc/eclipse/java_home to standard output.

#!/bin/bash
javainterpreter=`update-alternatives --display java|grep 'link currently points to'|awk '{print $5}'`
myjavahome=`cat /etc/eclipse/java_home|awk -v interpret="$javainterpreter" 'interpret ~ $0 {print}'`
cat /etc/eclipse/java_home|awk -v myhome="$myjavahome" 'BEGIN {print myhome} myhome !~ $0 {print}'|grep -v '^$'|grep -v '^#'

Regards

Erich Pawlik

description: updated
description: updated
Aldous Peñaranda (dous)
Changed in eclipse:
assignee: nobody → motujava
Revision history for this message
Joachim Beckers (jbeckers) wrote :

With the new sun-java5 packages, eclipse won't run.

A popup box says:
"The custom vm you have chosen is not a valid executable."

On the command line:
joachim@madkeunnen:~$ eclipse
using specified vm: /usr/lib/j2sdk1.5-sun

This is the same problem as above, that is: eclipse doesn't follow the settings provided by /etc/alternatives (where I have /usr/lib/jvm/java-1.5.0-sun set), but uses the $JAVA_HOME. If I set that to /usr/lib/jvm/java-1.5.0-sun, everything works fine.

Changed in eclipse:
status: Unconfirmed → Confirmed
Revision history for this message
Erich Pawlik (erichpawlik) wrote :

The situation described by Joachim Beckers has another twist: /etc/eclipse/java_home doesn't contain /usr/lib/jvm/java-1.5.0-sun. If I don't set $JAVA_HOME and the new sun-java5 package is the only Java package that is installed on the system, Eclipse no longer will work.

Btw: My proposed fix assumes that /etc/eclipse/java_home contains the correct path to the jvm and therefore doesn't work any more.

Revision history for this message
Erich Pawlik (erichpawlik) wrote :

See also bug #45347

Revision history for this message
Dennis Kaarsemaker (dennis) wrote : Re: [Bug 36534] Re: [Reopened] [Dapper] Eclipse startup script should respect jwm setting via update-alternatives

Jochim, Erich - that is a very different bug which is already filed
serveral times. Please look at the manpage for update-java-alternatives

Revision history for this message
Dennis Kaarsemaker (dennis) wrote : Re: [Bug 36534] Re: [Bug 36534] Re: [Reopened] [Dapper] Eclipse startup script should respect jwm setting via update-alternatives

Ehrm, I forgot that eclipse is being weird about this - sorry

Revision history for this message
R. A. Rivas Diaz (rivasdiaz) wrote :

I have described a way to solve this problem, but on a bug reported against java-common, the bug #45348.

If java-common is updated with my proposed solution (and the jdks and jres), then eclipse only have to use the same scheme, and with my patch to bug #45347 the problem is solved, although a simpler patch could also work.

Revision history for this message
ashok (asoka250) wrote :

This bug is already present in windows too, eclipse 3.0 version goes along with java 1.4.x and below versions, i think its the problem with the eclipse package,

Revision history for this message
auspex (auspex) wrote :

I agree with Erich (& Dennis - I'm not sure why you retracted your comment!)

update-alternatives (and update-alternatives-java) are the _proper_ way to set your default VM. eclipse should be respecting that.

I agree that "update-alternatives is not able to handle JAVA_HOME" is an unconvincing argument. Eclipse sets JAVA_HOME for itself, and should use the alternatives system to find where that should be.

Revision history for this message
David Császár (p5) wrote :

i'm also stuck on this.
- installed java-5
- installed eclipse
-> eclipse ran fine
- installed java-6
- uninstalled java-5
-> eclipse from the menu gives: The custom VM you have chosen is not a valid executable.
- uninstalled completely/reinstalled eclipse
-> same problem

eclipse from the command line is fine w/ and w/o JAVA_HOME

Changed in eclipse:
status: Unknown → New
Revision history for this message
George Pollard (porges) wrote :

The sanest fix should be to have "/etc/eclipse/java_home" have "/usr/lib/jvm/default-java" as the first line.

Revision history for this message
auspex (auspex) wrote : Re: [Bug 36534] Re: [Reopened] [Dapper] Eclipse startup script should respect jwm setting via update-alternatives

On October 28, 2008 04:09:59 George Pollard wrote:
> The sanest fix should be to have "/etc/eclipse/java_home" have
> "/usr/lib/jvm/default-java" as the first line.

Not very useful if you don't have such a file! The point of using
update-alternatives is that this is the way that java (and other) packages
are supposed to set the default for use by any applications - so Eclipse
should respect that, instead of using its own settings. If I use
update-alternatives or the more specific update-java-alternatives to set a
VM, then "/usr/bin/javac" and "/usr/bin/java" point to the java I've chosen,
via /etc/alternatives - eclipse should be able to do the same.
--
derek

Revision history for this message
Wolf von Bleichert (wolf-von-bleichert-koeln) wrote :

Well, I had the same error (the vm ....) after upgrading ubuntu 8 to 9.
I'd installed java-6-sun-1.6.0.13 but after the update my $JAVA_HOME pointed to java-6-sun-1.6.0.10.
Crap! Short discussion with my environment settings does not solve the problem. :-(
Checking out "/usr/bin/java" I saw that "someone" changed the link too.
Yeap!
Instead of linking "/usr/bin/java" to "/usr/lib/jvm/java-6-sun-1.6.0.13/jre/bin/java" there was this @³½¬! version 1.6.0.10 again.
Fixing the link solved all problems. Sun rises:-).

Does some nerd wrote an ubuntu update routine that kills my environment this way?
Go and get him!
Nail his fingers to the keyboard!
:-) No, just kidding! Errors making you human buddy! :-)
Maybe I overlooked something too!

Revision history for this message
Philippe Coval (rzr) wrote :

hi,
here is an offtopic question :

About your script, is there a policy to setup jvm per applications ?
For tuxguitar package I had to write a script that guess best installed jvm, but i am not very proud of it ...

Regards

Revision history for this message
Niels Thykier (niels-thykier) wrote :

We will try to fix this in eclipse 3.5.0-1

~Niels

Changed in eclipse (Ubuntu):
assignee: MOTU Java Growers (motujava) → Niels Thykier (niels-thykier)
status: Confirmed → In Progress
Revision history for this message
Niels Thykier (niels-thykier) wrote :

There are no longer any special hacks from our side that chooses the JVM.

~Niels

Changed in eclipse (Ubuntu):
status: In Progress → Fix Released
Changed in eclipse (Debian):
status: New → Fix Committed
Changed in eclipse (Debian):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.