jpackage on Mac

Henri Tremblay henri.tremblay at
Fri Jan 10 16:38:00 UTC 2020


I'm experiencing something strange when trying jpackage on mac. Using Java
14-ea+29-1384. I'm probably some noobs doing something wrong but just in
case I'm not, here it is.

There seem to be something wrong going on under the hood. I have a really
simple class. I tried with a really simple class.

package app;

import javax.swing.JFrame;

public class MyApp {
  public static void main(String... args) {
    JFrame frame = new JFrame("Hello!");
    frame.setSize(640, 480);

Then, I want to create a package for it.

javac -d classes src/app/
jar cvf bin/myapp.jar -C classes .
jpackage --name myapp --input bin --main-jar myapp.jar --main-class app.MyApp

To optimize the size of the package, I then did.

jlink --add-modules java.base,java.desktop --output myjre
jpackage --name myapp --input bin --main-jar myapp.jar --main-class
app.MyApp --runtime-image myjre

I also played with having a real module.

module app {
  requires java.desktop;

javac -d classes src/app/ src/
jar cvf bin/myapp.jar -C classes .
java --module-path bin -m app/app.MyApp
jpackage --name myapp --input bin --main-jar myapp.jar --main-class app.MyApp

I did that many times but the size of my final app isn't coherent.
I haven't found a logical pattern yet.

Basically, I get two results, one is 361Mb and the other is 126Mb. But not
when expected. So I would sometime create a package using modules and get
361Mb. Or create a package using the full JDK and get 126Mb.

So, there seem to be some weird cache somewhere that causes the wrong
content to go in the package when creating the same one twice.

Is it something someone experienced?


More information about the jdk-dev mailing list