Search code examples
javalinuxmacosjlink

Creating osx java app distribution on linux host


I'm working on a java app (linux, java 10+) that I want to distribute natively in other platforms. I successfully build a windows dist: jlinked in linux with a java 10+ windows dist, i.e., it created a directory with my module, java.exe and respective dlls (I verified that it worked on windows).

The problem is that when I want build an OSX dist (linux java 10 jlink + OSX java 10 dist), the resulting folder has java linux executable and the linux SO libraries instead osx dylib libs.

The command line that I'm using is (this is working for linux and windows):

${JAVA_HOME}/bin/jlink --compress 2 --no-header-files --module-path target/classes/:"$TARGET_JDK_PATH"/jmods/ --add-modules jdk.crypto.cryptoki,$MODULE_NAME --output $OUTPUT_DIR

I tried too

"$TARGET_JDK_PATH"/Contents/Home/jmods/

Linux and OSX Java version are 11.0.2.

Thanks in advance.


Solution

  • I solved it!

    Can't use JDK 10 (jlink) to build a dist with target JDK 11 (jmods). Besides, must specify

    <target.osx.jdk>/Contents/Home/jmods

    as "jmods" directory.

    Anyway, thank you for the ideas&suggestions.