Access to java compiler in Linux

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Access to java compiler in Linux

JiHO-2
Hello everyone,

I am trying to get ImageJ to compile a plugin on Linux and cannot find  
how to set my Java environment properly.

I start ImageJ from the command line with something like:
         java -jar ij.jar -ijpath path/to/plugins/

When I try to compile my plugin I get a message saying:
         "This JVM does not include the javac compiler
         ...
         [OK]
         "
while it does:
         $ which javac
         /usr/bin/javac

         $ readlink -f $(which javac)
         /usr/lib/jvm/java-6-sun-1.6.0.13/bin/javac
This installation is Sun's Java on Ubuntu.

When I start ImageJ with an explicit classpath
         java -cp /usr/lib/jvm/java-6-sun-1.6.0.13/lib/
tools.jar:ij.jar ij.ImageJ -ijpath path/to/plugins/
it works.

But I would prefer if it worked with a simple command line and by  
setting environment variables (the code in which I call ImageJ should  
work cross platform when the user set's the environment correctly).  
Setting
         JAVA_HOME to /usr/lib/jvm/java-6-sun-1.6.0.13/
         CLASSPATH to /usr/lib/jvm/java-6-sun-1.6.0.13/lib
or even
         CLASSPATH to /usr/lib/jvm/java-6-sun-1.6.0.13/lib/tools.jar
and using
         java -jar ij.jar -ijpath path/to/plugins/
or
         java -cp ij.jar ij.ImageJ -ijpath path/to/plugins/
does not work.

Could someone point me towards the correct configuration please?

PS: as a side note, is there a way to compile plugins on the command  
line, outside of ImageJ.

Thanks in advance.

JiHO
---
http://jo.irisson.free.fr/
Reply | Threaded
Open this post in threaded view
|

Re: Access to java compiler in Linux

dscho
Hi,

On Tue, 9 Jun 2009, JiHO wrote:

> I am trying to get ImageJ to compile a plugin on Linux and cannot find
> how to set my Java environment properly.
>
> I start ImageJ from the command line with something like:
>        java -jar ij.jar -ijpath path/to/plugins/
>
> When I try to compile my plugin I get a message saying:
>        "This JVM does not include the javac compiler
>        ...
>
> [...]
>
> But I would prefer if it worked with a simple command line and by
> setting environment variables (the code in which I call ImageJ should
> work cross platform when the user set's the environment correctly).

If you want something easy that works out of the box, try Fiji
(http://pacific.mpi-cbg.de/).

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: Access to java compiler in Linux

Boris Epstein
Johannes Schindelin wrote:

> Hi,
>
> On Tue, 9 Jun 2009, JiHO wrote:
>
>  
>> I am trying to get ImageJ to compile a plugin on Linux and cannot find
>> how to set my Java environment properly.
>>
>> I start ImageJ from the command line with something like:
>>        java -jar ij.jar -ijpath path/to/plugins/
>>
>> When I try to compile my plugin I get a message saying:
>>        "This JVM does not include the javac compiler
>>        ...
>>
>> [...]
>>
>> But I would prefer if it worked with a simple command line and by
>> setting environment variables (the code in which I call ImageJ should
>> work cross platform when the user set's the environment correctly).
>>    
>
> If you want something easy that works out of the box, try Fiji
> (http://pacific.mpi-cbg.de/).
>
> Ciao,
> Dscho
>  

What Linux distribution is this? Which version of Java?
--
*Boris Epstein
National Resource For Imaging Mass Spectrometry
<http://www.nrims.hms.harvard.edu/>
Cambridge, MA
Mobile: (617) 816-9654*


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.
Reply | Threaded
Open this post in threaded view
|

Re: Access to java compiler in Linux

ctrueden
In reply to this post by JiHO-2
Hi JiHO,


> PS: as a side note, is there a way to compile plugins on the command line,
> outside of ImageJ.
>

In general, with Java 1.6+ you should be able to use something like:

  javac -cp /path/to/ImageJ/ij.jar:/path/to/ImageJ/plugins/* My_Plugin.java

You may run into trouble if you have JAR dependencies in subfolders of
plugins, but if your build configuration is getting that complicated I
suggest you keep ij.jar somewhere as a separate dependency and build
everything totally outside the ImageJ directory structure. That's how we
build the LOCI plugins.

-Curtis

On Tue, Jun 9, 2009 at 6:06 PM, JiHO <[hidden email]> wrote:

> Hello everyone,
>
> I am trying to get ImageJ to compile a plugin on Linux and cannot find how
> to set my Java environment properly.
>
> I start ImageJ from the command line with something like:
>        java -jar ij.jar -ijpath path/to/plugins/
>
> When I try to compile my plugin I get a message saying:
>        "This JVM does not include the javac compiler
>        ...
>        [OK]
>        "
> while it does:
>        $ which javac
>        /usr/bin/javac
>
>        $ readlink -f $(which javac)
>        /usr/lib/jvm/java-6-sun-1.6.0.13/bin/javac
> This installation is Sun's Java on Ubuntu.
>
> When I start ImageJ with an explicit classpath
>        java -cp /usr/lib/jvm/java-6-sun-1.6.0.13/lib/tools.jar:ij.jar
> ij.ImageJ -ijpath path/to/plugins/
> it works.
>
> But I would prefer if it worked with a simple command line and by setting
> environment variables (the code in which I call ImageJ should work cross
> platform when the user set's the environment correctly). Setting
>        JAVA_HOME to /usr/lib/jvm/java-6-sun-1.6.0.13/
>        CLASSPATH to /usr/lib/jvm/java-6-sun-1.6.0.13/lib
> or even
>        CLASSPATH to /usr/lib/jvm/java-6-sun-1.6.0.13/lib/tools.jar
> and using
>        java -jar ij.jar -ijpath path/to/plugins/
> or
>        java -cp ij.jar ij.ImageJ -ijpath path/to/plugins/
> does not work.
>
> Could someone point me towards the correct configuration please?
>
> PS: as a side note, is there a way to compile plugins on the command line,
> outside of ImageJ.
>
> Thanks in advance.
>
> JiHO
> ---
> http://jo.irisson.free.fr/
>
Reply | Threaded
Open this post in threaded view
|

Re: Access to java compiler in Linux

dscho
In reply to this post by Boris Epstein
Hi,

please, please, please: if you do not want me to miss your mail, reply to
me, Cc:ing the list.  It is pure luck that I did not miss this answer.

On Tue, 16 Jun 2009, Boris Epstein wrote:

> Johannes Schindelin wrote:
> > Hi,
> >
> > On Tue, 9 Jun 2009, JiHO wrote:
> >
> >  
> >> I am trying to get ImageJ to compile a plugin on Linux and cannot find
> >> how to set my Java environment properly.
> >>
> >> I start ImageJ from the command line with something like:
> >>        java -jar ij.jar -ijpath path/to/plugins/
> >>
> >> When I try to compile my plugin I get a message saying:
> >>        "This JVM does not include the javac compiler
> >>        ...
> >>
> >> [...]
> >>
> >> But I would prefer if it worked with a simple command line and by
> >> setting environment variables (the code in which I call ImageJ should
> >> work cross platform when the user set's the environment correctly).
> >>    
> >
> > If you want something easy that works out of the box, try Fiji
> > (http://pacific.mpi-cbg.de/).
> >
> > Ciao,
> > Dscho
> >  
>
> What Linux distribution is this? Which version of Java?

No Linux distribution: Fiji.  (Following the link should tell you that
much.)

Java: except for MacOSX (where we are legally disallowed to distribute
Apple's Java) it is Java6.

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: Access to java compiler in Linux

JiHO-2
In reply to this post by dscho
On 2009-June-16  , at 17:56 , Johannes Schindelin wrote:

> If you want something easy that works out of the box, try Fiji
> (http://pacific.mpi-cbg.de/).

In my case, ImageJ is integrated within a complete software system and  
I want to keep the dependencies at minimum. So, while Fiji is nice, it  
is not useful here.

Thanks for your reply.

JiHO
---
http://maururu.net
Reply | Threaded
Open this post in threaded view
|

Re: Access to java compiler in Linux

JiHO-2
In reply to this post by Boris Epstein
On 2009-June-16  , at 17:57 , Boris Epstein wrote:

> What Linux distribution is this? Which version of Java?

As mentioned in my original message ( ;) ) it's Java 1.6 on Ubuntu 9.04.

But Wayne actually replied me off-list and I should have followed up  
here. Putting tool.jar in /usr/lib/jvm/java-6-sun-1.6.0.13/jre/lib/
ext/ solves the issue.

Thanks anyway.

JiHO
---
http://maururu.net
Reply | Threaded
Open this post in threaded view
|

Re: Access to java compiler in Linux

JiHO-2
In reply to this post by ctrueden
On 2009-June-16  , at 18:12 , Curtis Rueden wrote:

>> PS: as a side note, is there a way to compile plugins on the  
>> command line,
>> outside of ImageJ.
>
> In general, with Java 1.6+ you should be able to use something like:
>
>  javac -cp /path/to/ImageJ/ij.jar:/path/to/ImageJ/plugins/*  
> My_Plugin.java
>
> You may run into trouble if you have JAR dependencies in subfolders of
> plugins, but if your build configuration is getting that complicated I
> suggest you keep ij.jar somewhere as a separate dependency and build
> everything totally outside the ImageJ directory structure. That's  
> how we
> build the LOCI plugins.

It is a very simple plugin that only uses core ImageJ functionality  
(well, at the moment anyway) so this advice is very useful. Thanks.

JiHO
---
http://maururu.net
Reply | Threaded
Open this post in threaded view
|

Re: Access to java compiler in Linux

dscho
In reply to this post by JiHO-2
Hi,

On Tue, 16 Jun 2009, JiHO wrote:

> On 2009-June-16  , at 17:56 , Johannes Schindelin wrote:
>
> >If you want something easy that works out of the box, try Fiji
> >(http://pacific.mpi-cbg.de/).
>
> In my case, ImageJ is integrated within a complete software system and I
> want to keep the dependencies at minimum. So, while Fiji is nice, it is
> not useful here.

You might want to copy javac.jar from Fiji's jars/ directory to your
ImageJ's plugins/ directory.

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: Access to java compiler in Linux

dscho
In reply to this post by JiHO-2
Hi,

On Tue, 16 Jun 2009, JiHO wrote:

> But Wayne actually replied me off-list and I should have followed up
> here. Putting tool.jar in /usr/lib/jvm/java-6-sun-1.6.0.13/jre/lib/ext/
> solves the issue.

You mean tools.jar, not tool.jar.  And this is a solution you cannot
legally distribute, except if you distribute the complete JDK.  In
contrast, Fiji's javac.jar is derived from OpenJDK under the GPL, so you
are legally entitled to distribute it as long as you promise to provide
the sources for free (or almost free).

So if you want to copy your setup somewhere else, I'd strongly advise to
distribute the javac.jar.

Ciao,
Dscho "who had to cope with tedious license issues today"
Reply | Threaded
Open this post in threaded view
|

Re: Access to java compiler in Linux

JiHO-2
On 2009-June-16  , at 19:54 , Johannes Schindelin wrote:

> On Tue, 16 Jun 2009, JiHO wrote:
>
>> But Wayne actually replied me off-list and I should have followed up
>> here. Putting tool.jar in /usr/lib/jvm/java-6-sun-1.6.0.13/jre/lib/
>> ext/
>> solves the issue.
>
> You mean tools.jar, not tool.jar.  And this is a solution you cannot
> legally distribute, except if you distribute the complete JDK.  In
> contrast, Fiji's javac.jar is derived from OpenJDK under the GPL, so  
> you
> are legally entitled to distribute it as long as you promise to  
> provide
> the sources for free (or almost free).
>
> So if you want to copy your setup somewhere else, I'd strongly  
> advise to
> distribute the javac.jar.

Thanks, that a good point. The software toolchain is indeed entirely  
GPL. I just installed Sun's java because I have had issues in the past  
with free JVMs, but that was a long time ago.

JiHO
---
http://maururu.net