Reduce your TCO of building and using Spring Native applications with just 3 steps. Switch to the best Unified Java Runtime. Learn More.

The latest builds of Liberica NIK 22.2.0 and 21.3.3 are out

Liberica Native Image Kit 22.2.0 and 21.3.3 builds are out


Published August 05, 2022


We are happy to announce the general availability of Liberica Native Image Kit (NIK) versions 22.2.0 and 21.3.3 as part of Critical Patch Update (CPU) release cycle. The builds contain several security fixes and enhancements.

Liberica Native Image Kit is a GraalVM-based tool that helps to convert JVM-based applications into native executables and thus minimizes resource consumption and accelerates the startup time of applications. Liberica NIK supports multiple system configurations and languages and is part of a Cloud Native Buildpack together with Spring, which enables seamless generation of native images with Spring Boot.

All Liberica NIK builds contain the latest version of Liberica JDK with fixes and eliminated security issues.

  1. Summary of fixes and enhancements
    1. List of security issues fixed
    2. Summary of fixes in Liberica NIK
  2. Enhanced AWT/Swing support
    1. Set up your workspace
    2. Generate configuration files
    3. Create a native image for SwingSet2 app (Linux and macOS)
    4. Create a native image for SwingSet2 app (Windows)
  3. Conclusion

Summary of fixes and enhancements

List of security issues fixed

CVE ID cvss score component module Attack vector (network/local) Complexity (low/high) Privileges (none/low) User interaction (none/required) Scope (changed/unchanged) Confidentiality (low/none/high) Integrity (low/none/high) Availability (low/none/high)
CVE-2022-34169 7.5 xml java.xml network low none none unchanged none high none
CVE-2022-21540 5.3 core-libs java.base network low none none unchanged low none none
CVE-2022-21541 5.9 core-libs java.base network high none none unchanged none high none
CVE-2022-21549 5.3 core-libs java.base network low none none unchanged none low none

Summary of fixes in Liberica NIK

CVEs fixed in Liberica NIK per version:

CVE JBS CVSS 21.3.3 (JDK 11) 21.3.3 (JDK 17) 22.2.0 (JDK 11) 22.2.0 (JDK 17)
CVE-2022-34169 8285407 7.5
CVE-2022-21540 8281859 5.3
CVE-2022-21541 8281866 5.9
CVE-2022-21549 8283875 5.3 - -

Enhanced AWT/Swing support

In the previous Liberica NIK release, we added support for AWT/Swing for Linux. Now we extend the support to Windows and macOS. In the case of GraalVM with JDK 11 or 17 on Windows, an application will be converted into a native executable plus dynamic libraries necessary for AWT/Swing and taken from the JDK. As far as macOS is concerned, an app will be transformed into a single native executable.

Below you will find the detailed instructions on how to create native images of a SwingSet2 demo app using Liberica NIK for three platforms — Linux, macOS, and Windows.

Set up your workspace

First, download Liberica Native Image Kit for your platform. Refer to the Install Guide for installation instructions. Set the PATH variable to Liberica NIK:

PATH=<path-to-nik>/bin:$PATH

Download JDK 8 demos with SwingSet2. You will find the app in the demo/jfc/SwingSet2 folder upon archive extraction.

Generate configuration files

The next step is to create configuration files specific to the SwingSet2 demo using a native image agent.

  1. Run java from Native Image Kit with “-agentlib:native-image-agent=config-output-dir=conf-dir” parameters

     java -agentlib:native-image-agent=config-output-dir=conf-dir -jar SwingSet2.jar
    
  2. Click on several demo tabs and select several Look & Feels from “Look & Feel” menu
  3. Close the SwingSet2 demo

    The directory conf-dir contains configuration files in JSON format.

    • The reflect-config.json file describes classes that will be accessed reflectively from the demo. It includes both the reflection classes related to the SwingSet2 demo and to JDK classes. Edit the reflect-config.json file to leave only the description for SwingSet2 demo classes accessed by reflection. You need to leave only the reflections related to the SwingSet2 demo. Below you will find the adjusted reflect-config.json file.
[
{
  "name":"ButtonDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"ColorChooserDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"ComboBoxDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"FileChooserDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"HtmlDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"ListDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"OptionPaneDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"ProgressBarDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"ScrollPaneDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"SliderDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"SplitPaneDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"TabbedPaneDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"TableDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"ToolTipDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
},
{
  "name":"TreeDemo",
  "methods":[{"name":"<init>","parameterTypes":["SwingSet2"] }]
}
]
  • The resource-config.json file defines resources that should be accessible at image run time. It includes both resources related to SwingSet2 demo and for Swing Look&Feels. Edit the resource-config.json file to leave only the resources related to the SwingSet2 demo. Find the adjusted resource-config.json file below.
{
  "resources":{
  "includes":[
    {
      "pattern":"\\QButtonDemo.java\\E"
    },
    {
      "pattern":"\\QColorChooserDemo.java\\E"
    },
    {
      "pattern":"\\QComboBoxDemo.java\\E"
    },
    {
      "pattern":"\\QFileChooserDemo.java\\E"
    },
    {
      "pattern":"\\QHtmlDemo.java\\E"
    },
    {
      "pattern":"\\QInternalFrameDemo.java\\E"
    },
    {
      "pattern":"\\QListDemo.java\\E"
    },
    {
      "pattern":"\\QOptionPaneDemo.java\\E"
    },
    {
      "pattern":"\\QProgressBarDemo.java\\E"
    },
    {
      "pattern":"\\QScrollPaneDemo.java\\E"
    },
    {
      "pattern":"\\QSliderDemo.java\\E"
    },
    {
      "pattern":"\\QSplitPaneDemo.java\\E"
    },
    {
      "pattern":"\\QTabbedPaneDemo.java\\E"
    },
    {
      "pattern":"\\QTableDemo.java\\E"
    },
    {
      "pattern":"\\QToolTipDemo.java\\E"
    },
    {
      "pattern":"\\QTreeDemo.java\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/apple.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/asparagus.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/banana.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/broccoli.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/cantaloupe.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/carrot.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/corn.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/grapefruit.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/grapes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/kiwi.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/onion.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/peach.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/pear.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/pepper.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/pickle.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/pineapple.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/raspberry.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/strawberry.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/tomato.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/food/watermelon.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/misc/cab.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/misc/cab_small.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/misc/fish.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/misc/fish_small.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/misc/moon.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/misc/moon_small.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/misc/sun.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/ImageClub/misc/sun_small.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b1.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b1d.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b1p.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b1r.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b2.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b2d.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b2p.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b2r.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b3.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b3d.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b3p.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/b3r.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/bl.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/bldn.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/bm.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/bmdn.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/br.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/brdn.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/c.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/cb.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/cbr.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/cbrs.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/cbs.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/cdn.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/ml.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/mldn.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/mr.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/mrdn.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/rb.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/rbp.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/rbr.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/rbrs.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/rbs.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/tl.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/tldn.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/tm.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/tmdn.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/tr.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/buttons/trdn.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/brenteyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/brenthair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/brentmouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/georgeseyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/georgeshair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/georgesmouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/hanseyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/hanshair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/hansmouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/howardeyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/howardhair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/howardmouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/jameseyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/jameshair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/jamesmouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/jeffeyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/jeffhair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/jeffmouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/joneyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/jonhair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/jonmouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/laraeyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/larahair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/laramouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/larryeyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/larryhair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/larrymouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/lisaeyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/lisahair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/lisamouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/michaeleyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/michaelhair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/michaelmouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/philipeyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/philiphair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/philipmouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/scotteyes.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/scotthair.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/combobox/scottmouth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/filechooser/find.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/filechooser/gifIcon.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/filechooser/help.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/filechooser/jpgIcon.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/list/blue.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/list/cyan.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/list/gray.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/list/green.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/list/magenta.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/list/red.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/list/yellow.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/optionpane/bottle.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/scrollpane/colheader.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/scrollpane/crayons.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/scrollpane/lowerleft.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/scrollpane/rowheader.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/scrollpane/upperleft.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/scrollpane/upperright.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/splitpane/earth.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/splitpane/moon.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/tabbedpane/blake.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/tabbedpane/brooke.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/tabbedpane/david.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/tabbedpane/ewan.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/tabbedpane/ewan.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/tabbedpane/hania.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/tabbedpane/laine.jpg\\E"
    },
    {
      "pattern":"\\Qresources/images/tabbedpane/matthew.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/tabbedpane/stephen.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JButton.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JColorChooser.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JComboBox.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JDesktop.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JEditorPane.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JFileChooser.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JList.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JOptionPane.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JProgressBar.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JScrollPane.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JSlider.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JSplitPane.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JTabbedPane.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JTable.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/JTree.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/toolbar/ToolTip.gif\\E"
    },
    {
      "pattern":"\\Qresources/images/tooltip/cow.gif\\E"
    },
    {
      "pattern":"\\Qresources/index.html\\E"
    },
    {
      "pattern":"\\Qresources/swingset.properties\\E"
    },
    {
      "pattern":"\\Qresources/tree.txt\\E"
    }
  ]},
  "bundles":[
    {
      "name":"resources.swingset"
    }
  ]
}
  1. Set java.awt.headless Java property explicitly to false:

     -Djava.awt.headless=false
    

Create a native image for SwingSet2 app (Linux and macOS)

To build the native image, you need to provide the resource and reflection files apart from stating the java.awt.headless property. Run the following command

native-image -Djava.awt.headless=false -H:ReflectionConfigurationFiles=conf-dir/reflect-config.json -H:ResourceConfigurationFiles=conf-dir/resource-config.json -jar SwingSet2.jar

alt_text

Metal Look&Feel (Linux)

A note for macOS users — to run the application, go to the app directory and use the following command:

./SwingSet2

alt_text

Aqua Look&Feel (macOS)

Create a native image for SwingSet2 app (Windows)

You need to have Microsoft Visual Studio installed to create a native image.

To set the environment required for Microsoft Visual Studio, run the vcvars64.bat file:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat

After that, provide the resource and reflection files. To enable HiDPI support, provide the manifest file “SwingSet2.exe.manifest”, where

  • dpi1:dpiAware is set to true/PM
  • dpi2:dpiAwareness is set to PerMonitorV2, PerMonitor, system

Finally, the command for generating a native image is as follows:

native-image.cmd  -Djava.awt.headless=false -H:ReflectionConfigurationFiles=conf-dir/reflect-config.json -H:ResourceConfigurationFiles=conf-dir/resource-config.json -jar SwingSet2.jar

As a result, the SwingSet2.exe and SwingSet2.exe.manifest will be produced.

alt_text

Windows Look&Feel (Windows)

Conclusion

BellSoft strives to provide Java developers with a full stack of secure and affordable technologies suitable for creating a wide range of applications. Not only does Liberica Native Image Kit enable you to create performant microcontainers with minimal startup time, it enhances the experience of working with Swing and AWT apps. Download the latest version of Liberica NIK now!

Announcements
Author image

Peter Zhelezniakov

Software Engineer at BellSoft