Login  Register

Re: Java, Linking and Portability

Posted by dscho on Sep 12, 2014; 8:18am
URL: http://imagej.273.s1.nabble.com/Java-Linking-and-Portability-tp5009568p5009598.html

Hi Benjamin,

at LOCI we like to take conversations private only when there is a benefit
in doing so (see http://loci.wisc.edu/software/developing-loci-software
section 'Mailing Lists'). In this particular case, I actually see the
opposite of a benefit in taking the conversation private, so I re-Cc: the
list. Please let me know if you are not okay with that.

On Wed, 10 Sep 2014, Benjamin Eltzner wrote:

> >> So far my program only uses the Java class library, so I can develop
> >> on Linux and distribute a runnable jar that will run on Windows,
> >> Linux and Mac.
> >
> > You have been avoiding what has been called "dependency hell". That is
> > sustainable if you develop alone, but if you want to develop together,
> > you need proper dependency management.
> >
> > By proper dependency management, I refer to a way to declare which
> > dependencies (and which versions thereof) your primary project depends
> > on.
> >
> > As we had the problem you described in Fiji, ever since its beginning,
> > I daresay we have quite a bit of experience with it, and the best
> > solution we could come up with is called Maven
> > (http://imagej.net/Maven)
>
> thank you very much for your suggestion. If I understand the explanation
> of Maven correctly, the workflow would be,
> 1. list my dependencies in a pom.xml file
> 2. tell Maven to download them
> 3. distribute my program with all the jar files Maven fetched

Almost. You do not need to tell Maven to download dependencies. You also
do not distribute the dependencies explicitly.

Instead, the workflow is something like this:

        1) Develop your plugin in an IDE such as Netbeans

        2) When satisfied that it works as intended, i.e. when all the
           unit tests pass, you install your plugin into an existing,
           up-to-date Fiji (downloaded and unpacked from http://fiji.sc/):

                mvn -Dimagej.app.directory=/path/to/Fiji.app

           This will automatically install also the dependencies that are
           not present in that Fiji installation yet.

        3) *Test the plugin in Fiji*

        4) Start the updater with Help>Update... and upload to your update
           site (initializing your own personal update site if you have
           not done so yet).

           The updater will suggest to upload dependencies that are not
           available in Fiji yet, too.

Of course you can also distribute your own ImageJ with your plugin, in a
more manual process, but then you should not ask the person who worked so
hard to make the process more automated ;-)

> or is it more like
> 2. use Maven to make an installer, which I distribute
> 3. the user launches the installer, which looks, whether a local maven
> repository is there, which prerequisites it already has and fetches
> missing dependencies to the users local maven repository from the remote
> repository I named in the pom.xml.
> ?

No, Maven is purely for use on the developers' side. The users will never
touch Maven.

> If I misunderstood the concept of Maven, I would be glad if you could
> elaborate a little more.

Well, I hoped that the page I created at http://imagej.net/Maven was clear
enough... Maven is a dependency management system that can also build your
project.

But I probably forgot to mention the best part about Maven: the
configuration is so standardized that other software, including Netbeans
and Eclipse, can interpret the project configuration without calling the
Maven software itself. Indeed, the project configuration is so easy to
interpret that even the ImageJ updater makes use of it to extract the
project description if it finds a .jar file including the Maven
configuration.

Ciao,
Johannes

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html