Producing "bundled" JREs for other platforms?

org.openjdk at io7m.com org.openjdk at io7m.com
Sun Jul 24 20:22:13 UTC 2016


'Ello.

On 2016-07-24T21:26:36 +0200
Claes Redestad <claes.redestad at oracle.com> wrote:
> Hi,
> 
> (disclaimer: I haven't verified this actually works. There might be
> bugs and lack of test coverage to fully support this)
> 
> the jmods shipped with the JDK are designed to be self-contained, e.g.,
> $JDK/jmods/java.base.jmod contain bin/java, shared libraries and the
> JVM itself; all resources in the resulting image (binaries etc) are derived
> not from the JDK running jlink, but from the jmods on which the jlink tool
> operates.

Interesting!

> That means it should be straightforward to produce a runnable image
> from any platform-specific JDK in a cross-platform manner by specifying
> --modulepath correctly.
> 
> Try downloading, say, the latest OS X build to foo and try this (using
> your native JDK):
> 
> $JAVA_HOME/bin/jlink --modulepath foo/jmods --addmods java.se.ee 
> --output bar
> 
> bar should now contain an image natively runnable on OS X.

I see. That's certainly better than having the jlink tool know about a
list of "supported" platforms.

I'm curious whether or not this can be used to produce images that run
on a range of platforms.

The way I distribute actual application code right now is that I have a
directory structure with something like the following:

  application-1.0/
    lib/
      application.jar
      library0.jar
      library1.jar
      ...
    application.exe
    application.sh
    ...

The "lib" directory contains the application jars and dependencies.

"application.exe" is a Windows executable produced by launch4j or
something similar, and "application.sh" is a shell script for
Unix-likes that simply sets up the classpath based on the contents of
"lib" and executes "java" with the main class as an argument. 

I don't currently have a more pleasant approach for OS X as Apple seem
to continually break things and don't provide cross-platform tools for
producing OS X "bundles".

I'm basically trying to work out how Jigsaw will let me do something
"better" than the above. As you can probably see, I strongly prefer
providing a single application package that works on as many platforms
as possible, with minimal platform-specific launchers for those
platforms that need them (as opposed to offering separate Linux,
Windows, OS X, etc, packages). I feel like I might be trying to do the
opposite of what Jigsaw provides by default.

M



More information about the jigsaw-dev mailing list