ubuntu 9.10 imagej "Plugins>Compile and Run..." does not work

Bug #486906 reported by Brian King
42
This bug affects 9 people
Affects Status Importance Assigned to Milestone
imagej (Debian)
Fix Released
Unknown
imagej (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: imagej

I upgraded from Ubuntu 9.04 (fresh install) to Ubuntu 9.10 just last night (great job, guys!). I opted to install the ImageJ package 1.43b-1ubuntu1 (http://ca.archive.ubuntu.com karmic/universe Packages). I can start ImageJ just fine from the Applications>Graphics menu (the graphical icon in this menu does "imagej %f" according to its Properties). It runs beautifully. BUT...

But when I select "Plugins>Compile and Run..." I get the error: "Unable to find the javac compiler, which comes with the Windows and Linux versions of ImageJ that include Java in the ImageJ/jre folder.<newline> java.home: /usr/lib/jvm/java-6-openjdk/jre" In this case, I'm trying to compile and run a Plugin (My_Integrator.java) in $HOME/.imagej/plugins.

So at this point, with apologies, it becomes confusing. I had been trying to get ImageJ running (same bug!) on 9.04, so my system's java use/preferences may have changed. So let me point out the following behaviours, for different choices of jre (using "sudo update-alternatives --config java" to toggle between different javas (javae??).

IF I CHOOSE "/usr/bin/gij-4.3" or "/usr/bin/gij-4.4", THEN I replicate Bug #471127. In this case, implementing the "hack" suggested by linuxed on that report/thread (editing "/usr/bin/imagej") has no effect and ImageJ will not launch from the Applications menu. Command-line launch gives the "Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit..." message which - at first glance - seems to be the same as in Bug #471127.

IF I CHOOSE "/usr/lib/jvm/java-6-openjdk/jre/bin/java" or "/usr/lib/jvm/java-6-sun/jre/bin/java" THEN ImageJ launches/runs great! However, when I attempt to "Plugins>Compile and Run..." I get the above error. (Sorry! NEED to get this running, and am a bit of a java newb, so though I understand repository-packagers aversion to non-free-as-in-freedom java environments, I downloaded the Sun jdk yesterday... and possibly Sun jre much earlier...)

I apologize if fixing Bug #471127 fixes this as well. But my guess is that perhaps the Ubuntu repository packaging has environment variables which aren't pointing in the correct place (I see that the package's imagej.jar has a "hack" in it from previous instances of this problem - found on the web...).

(Hopefully it will be possible to eventually just run ImageJ in all its functionality directly from the Applications menu...)

Revision history for this message
Alexandre Norman (norman-xael) wrote :

In my installation, in order to make it compile I had to do the following :
- install package sun-java6-jdk
- copy /usr/lib/jvm/java-6-sun-1.6.0.15/lib/tools.jar to /usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/ext/

then it worked !

Revision history for this message
Shane (shane-h-1) wrote :

I tried Alexandre's solution, to no avail, however it gave me the clue I needed to solve this issue with my install.

First, the error tells us that ImageJ is using /usr/lib/jvm/java-6-openjdk/jre,

ps ax |grep -i imagej confirms this:
 0:01 /usr/lib/jvm/java-6-openjdk/bin/java -mx370m -cp /usr/share/java/ij.jar ij.ImageJ -ijpath $HOME/.imagej -port1

the fix I used was:

$sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.20/lib/tools.jar /usr/lib/jvm/java-6-openjdk/jre/lib/ext/

Revision history for this message
Rorzik (rorzik) wrote :

I get the same "Unable to find the javac compiler ..." error as above, with 10.10. It is for some reason searching under jre for the javac binary (and other components) when the compiler is not part of jre but the jdk. The fix is very simple:

I opened /usr/bin/imagej, scrolled to the very bottom where it has the line:

eval $JAVA_HOME/bin/java ${arch} -mx${mem}m ${jni} ${modules} ij.ImageJ -ijpath ${ij_user_path} -port${count} ${images} ${macrocmd} ${macroargs}

And I deleted the "$JAVA_HOME/bin/", changing it to:

eval java ${arch} -mx${mem}m ${jni} ${modules} ij.ImageJ -ijpath ${ij_user_path} -port${count} ${images} ${macrocmd} ${macroargs}

That completely fixed the problem for me. It finds java just fine using the path, only when it's using the path it also uses the path for javac, and then finds that too. When $JAVA_HOME was forcing it into the jre directory, it seemed to force it to only look there for javac. Perhaps this is a more general solution than the above ones (which were not sufficient to fix it for me, but which did point me in this direction).

Revision history for this message
vinay pai (paiv) wrote :

Actually, Shane's approach works for me. The only addition I had to do was export JAVA_HOME="/usr/lib/jvm/java-6-openjdk

I am running ubuntu natty narwhal, and I tried the delete $JAVA_HOME approach, but I think that is not needed. The linking of the tools.jar resolved it.

Revision history for this message
vinay pai (paiv) wrote :

Oops, forgot the " at the backend of the export statement (but I assume most admins figured that out).

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in imagej (Ubuntu):
status: New → Confirmed
Revision history for this message
Andrew (andrewkvalheim) wrote :

This problem still occurs in Ubuntu 11.10. Shane's workaround worked for me.

Revision history for this message
oliford (oliford) wrote :

Same problem here on 11.10 with the source version of imaegJ.
Linking to tools.jar in /usr/lib/jvm/java-6-openjdk/jre/lib/ext/ fixes it.

Revision history for this message
Brian King (brian-king) wrote : RE: [Bug 486906] Re: ubuntu 9.10 imagej "Plugins>Compile and Run..." does not work
Download full text (3.6 KiB)

Aaargh!
This was years ago, now. Sorry, this happened so long ago I can't recall my workaround. At all.
If anything hits my synapses I'll post it. I'm pretty sure I found a way to compile... I'm pretty sure it involved some workaround.

Brian King

> Date: Tue, 3 Apr 2012 09:14:04 +0000
> From: <email address hidden>
> To: <email address hidden>
> Subject: [Bug 486906] Re: ubuntu 9.10 imagej "Plugins>Compile and Run..." does not work
>
> Same problem here on 11.10 with the source version of imaegJ.
> Linking to tools.jar in /usr/lib/jvm/java-6-openjdk/jre/lib/ext/ fixes it.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/486906
>
> Title:
> ubuntu 9.10 imagej "Plugins>Compile and Run..." does not work
>
> Status in “imagej” package in Ubuntu:
> Confirmed
>
> Bug description:
> Binary package hint: imagej
>
> I upgraded from Ubuntu 9.04 (fresh install) to Ubuntu 9.10 just last
> night (great job, guys!). I opted to install the ImageJ package 1.43b-
> 1ubuntu1 (http://ca.archive.ubuntu.com karmic/universe Packages). I
> can start ImageJ just fine from the Applications>Graphics menu (the
> graphical icon in this menu does "imagej %f" according to its
> Properties). It runs beautifully. BUT...
>
> But when I select "Plugins>Compile and Run..." I get the error:
> "Unable to find the javac compiler, which comes with the Windows and
> Linux versions of ImageJ that include Java in the ImageJ/jre
> folder.<newline> java.home: /usr/lib/jvm/java-6-openjdk/jre" In this
> case, I'm trying to compile and run a Plugin (My_Integrator.java) in
> $HOME/.imagej/plugins.
>
> So at this point, with apologies, it becomes confusing. I had been
> trying to get ImageJ running (same bug!) on 9.04, so my system's java
> use/preferences may have changed. So let me point out the following
> behaviours, for different choices of jre (using "sudo update-
> alternatives --config java" to toggle between different javas
> (javae??).
>
> IF I CHOOSE "/usr/bin/gij-4.3" or "/usr/bin/gij-4.4", THEN I replicate
> Bug #471127. In this case, implementing the "hack" suggested by
> linuxed on that report/thread (editing "/usr/bin/imagej") has no
> effect and ImageJ will not launch from the Applications menu. Command-
> line launch gives the "Exception in thread "main" java.awt.AWTError:
> Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit..." message
> which - at first glance - seems to be the same as in Bug #471127.
>
> IF I CHOOSE "/usr/lib/jvm/java-6-openjdk/jre/bin/java" or
> "/usr/lib/jvm/java-6-sun/jre/bin/java" THEN ImageJ launches/runs
> great! However, when I attempt to "Plugins>Compile and Run..." I get
> the above error. (Sorry! NEED to get this running, and am a bit of a
> java newb, so though I understand repository-packagers aversion to
> non-free-as-in-freedom java environments, I downloaded the Sun jdk
> yesterday... and possibly Sun jre much earlier...)
>
> I apologize if fixing Bug #471127 fixes this as well. But my guess is
> that perhaps the Ubuntu repository packaging has environment variables
...

Read more...

Revision history for this message
Rorzik (rorzik) wrote :

This bug is back in 12.04, and is not resolved with the tools.jar link workaround or with editing the launcher script as above. The problem has only gotten worse. Is there someone who knows how to actually fix this?

Revision history for this message
L e . N o X (le-nox) wrote :

Ubuntu 12.04 AMD64:

This is the solution with my configuration :

              sudo apt-get install openjdk-6-jdk

              sudo cp /usr/lib/jvm/java-1.6.0-openjdk-amd64/lib/tools.jar /usr/lib/jvm/java-1.6.0-openjdk-amd64/jre/lib/ext/

              wget http://rsbweb.nih.gov/ij/download/linux/ij145-x86.tar.gz
              tar -xf ij145-x86.tar.gz
              cd ImageJ/
              java -Xmx512m -jar ij.jar
;o)

Changed in imagej (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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