0

We are using JDK FX 17 from https://www.azul.com/downloads/#zulu

We build a custom Java runtime image using the following command

jlink --no-header-files --no-man-pages --compress=2 --strip-debug --module-path "C:\Program Files\Zulu\zulu-17\jmods" --add-modules java.base,java.datatransfer,java.desktop,java.logging,java.naming,java.prefs,java.rmi,java.security.sasl,java.sql,java.xml,javafx.base,javafx.controls,javafx.graphics,javafx.media,javafx.swing,javafx.web,jdk.jsobject,jdk.unsupported,jdk.crypto.ec --output jre

However, I notice I am getting different Swing app display quality, by using custom Java runtime image, and system installed Java.

This is how I execute my Java Swing app.

Using custom Java runtime image from jlink

C:\Users\yccheok\Desktop\jstock>jre\bin\java -Dsun.java2d.dpiaware=false -Xms64m  -Xmx512m --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED -jar jstock.jar

Here is the Swing app result. (You need to download the image in original size, to notice the UI display is blurry)

enter image description here


Using system installed Java

C:\Users\yccheok\Desktop\jstock>java -Dsun.java2d.dpiaware=false -Xms64m  -Xmx512m --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED -jar jstock.jar

enter image description here

If you compare both screenshots, you will notice the system installed Java, produce a Swing UI which is sharper and clearer. (You need to download the image in original size, to notice the UI display is sharp and clear)

Do you know why this is so? How I can fix my jlink output image?

Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
  • I guess you might need to include some additional JDK or JavaFX module which provides some different rendering pipeline or something. – Mark Rotteveel Jul 17 '23 at 09:37
  • Do you have idea how can I know which to include? I try to compare`-verbose` from 2 different Java (system Java and custom Java image), I do not get much useful information. – Cheok Yan Cheng Jul 17 '23 at 10:04
  • I've tried looking for anything obvious, but I don't know. – Mark Rotteveel Jul 17 '23 at 10:09
  • I would override the `paintComponent(Graphics g)` method of one of the JLabel and print the rendering hints values and compare both. If it's the same then the `UIDefaults`, then the system properties. – Anthony Jul 18 '23 at 20:18

0 Answers0