Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8326456

[macos] UnsatisfiedLinkError is thrown when an application attempts to load a native library libawt.dylib on headless

XMLWordPrintable

    • x86_64
    • os_x

      ADDITIONAL SYSTEM INFORMATION :
      System Version: macOS 10.15.7 (19H2026)
      Kernel Version: Darwin 19.6.0

      Hardware Overview:

        Model Name: MacBook Pro
        Model Identifier: MacBookPro10,1
        Processor Name: Quad-Core Intel Core i7


      A DESCRIPTION OF THE PROBLEM :
      import java.awt.*;

      public class Test {
        public static void main(String[] args) {
          GraphicsEnvironment.isHeadless();
        }
      }




      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the provided sample. I've tried the sample on different macOS computers and it always fails with UnsatisfiedLinkError error.

      ACTUAL -
      Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/vova/opt/testJdks/64/jdk-22/Contents/Home/lib/libawt.dylib: dlopen(/Users/vova/opt/testJdks/64/jdk-22/Contents/Home/lib/libawt.dylib, 1): Library not loaded: /System/Library/Frameworks/JavaRuntimeSupport.framework/Versions/A/JavaRuntimeSupport
        Referenced from: /Users/vova/opt/testJdks/64/jdk-22/Contents/Home/lib/libawt.dylib
        Reason: image not found
      at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
      at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
      at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
      at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
      at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:259)
      at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:249)
      at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2408)
      at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916)
      at java.base/java.lang.System.loadLibrary(System.java:2068)
      at java.desktop/sun.awt.PlatformGraphicsInfo.lambda$static$0(PlatformGraphicsInfo.java:38)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
      at java.desktop/sun.awt.PlatformGraphicsInfo.<clinit>(PlatformGraphicsInfo.java:37)
      at java.desktop/java.awt.GraphicsEnvironment.lambda$getHeadlessProperty$0(GraphicsEnvironment.java:150)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
      at java.desktop/java.awt.GraphicsEnvironment.getHeadlessProperty(GraphicsEnvironment.java:145)
      at java.desktop/java.awt.GraphicsEnvironment.isHeadless(GraphicsEnvironment.java:122)
      at Test.main(Test.java:7)

      ---------- BEGIN SOURCE ----------
      import java.awt.*;

      public class Test {
        public static void main(String[] args) {
          GraphicsEnvironment.isHeadless();
        }
      }

      Here is the output of "otool -L /Users/vova/opt/testJdks/64/jdk-22/Contents/Home/lib/libawt.dylib"

      /Users/vova/opt/testJdks/64/jdk-22/Contents/Home/lib/libawt.dylib:
      @rpath/libawt.dylib (compatibility version 1.0.0, current version 1.0.0)
      @rpath/libjvm.dylib (compatibility version 1.0.0, current version 1.0.0)
      @rpath/libjava.dylib (compatibility version 1.0.0, current version 1.0.0)
      /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)
      @rpath/libmlib_image.dylib (compatibility version 1.0.0, current version 1.0.0)
      /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 23.0.0)
      /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
      /System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 306.5.16)
      /System/Library/Frameworks/JavaRuntimeSupport.framework/Versions/A/JavaRuntimeSupport (compatibility version 1.0.0, current version 79.0.0)
      /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 61.0.0)
      /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1000.0.0)

      ---------- END SOURCE ----------

      FREQUENCY : always


            pnarayanaswa Praveen Narayanaswamy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: