-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.lang.UnsatisfiedLinkError: no awt in java.library.path #3575
Comments
I don't know if this is useful - or even helpful, but I took the above jar file to my Ubuntu Virtual machine, installed graalvm 21.1.0 there and tried to create a native image in Linux. But in Linux it doesn't even get through the native_image creation:
Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.graal.pointsto.util.AnalysisError: parsing had failed in another thread |
I would try JDK11 and latest dev build, I've had better success with that. |
Hi @twolf2919, I am taking care of this issue. |
@twolf2919,
The above property will force the native-image command to link with proper system library (libawt_xawt.a, instead of libawt_headless.a) to make a successful native executable for any Swing app. Hope the above can be applied to your Mac platform. FYI, I have compiled the SwingSet3 sample app to native image successfully in both Windows and Ubuntu, in my repo here. |
@chirontt - i’m sorry, but I must’ve missed the instructions about running native-image-agent when I followed the instructions. I have no idea about that command. Can you point me to instructions on how to accomplish that first bullet? |
Thanks for your notes @chirontt! @twolf2919, you can find more information on the native-image agent on the documentation page: I was able to build and run the native image. Please follow the instructions on the page, and if you have any problems, please reopen this ticket. |
You can manually copied some small files of the JAVA_HOME\lib to solve the problem in windows. And run with -Djava.home=. |
graalBug.jar.gz
graalBug.jar.gz
src.tar.gz
I created a native image of my Java swing application. But when I try to run the native image, I immediately get the error mentioned in the title. A previous issue, 2842 (#2842), described the same problem and was closed (as fixed?), but I tried both the currently released version 21.1.0 as well as the latest dev snapshot 21.3.0-dev and still get this error.
To reproduce the problem, simply try to create a native image from the attached jar file (see below for exact commands I used). I'm also including the source code (just 3 java files and an icon) in case you need that.
Specific versions of graal I tried:
graalvm-ce-java16-21.3.0-dev
graalvm-ce-java16-21.1.0
And compiled the source using the JDK (16) that came with these graal installs. This was done on macOS Monterey.
Below is the verbose output from running native_image and the exception that occur when I try to run the native image:
twolf@MacBook-Pro dist % native-image -H:+ReportExceptionStackTraces --no-fallback --allow-incomplete-classpath --native-image-info --verbose -jar graalBug.jar
Executing [
/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/bin/java
-XX:+UseParallelGC
-XX:+UnlockExperimentalVMOptions
-XX:+EnableJVMCI
-Dtruffle.TrustAllTruffleRuntimeProviders=true
-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime
-Dgraalvm.ForcePolyglotInvalid=true
-Dgraalvm.locatorDisabled=true
-Dsubstratevm.IgnoreGraalVersionCheck=true
--add-exports=java.base/jdk.internal.module=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED
--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.debug=ALL-UNNAMED
--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.nodes=ALL-UNNAMED
--add-opens=jdk.unsupported/sun.reflect=ALL-UNNAMED
--add-opens=java.base/jdk.internal.module=ALL-UNNAMED
--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens=java.base/jdk.internal.reflect=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
--add-opens=java.base/java.lang.ref=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/java.nio=ALL-UNNAMED
--add-opens=java.base/java.nio.file=ALL-UNNAMED
--add-opens=java.base/java.security=ALL-UNNAMED
--add-opens=java.base/javax.crypto=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
--add-opens=java.base/sun.security.x509=ALL-UNNAMED
--add-opens=java.base/jdk.internal.logger=ALL-UNNAMED
--add-opens=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED
--add-opens=org.graalvm.sdk/org.graalvm.polyglot=ALL-UNNAMED
--add-opens=org.graalvm.truffle/com.oracle.truffle.polyglot=ALL-UNNAMED
--add-opens=org.graalvm.truffle/com.oracle.truffle.api.impl=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED
--add-opens=java.base/sun.util.locale.provider=ALL-UNNAMED
--add-opens=java.base/sun.util.resources=ALL-UNNAMED
--add-opens=java.base/sun.security.util=ALL-UNNAMED
--add-opens=java.base/sun.util.calendar=ALL-UNNAMED
--add-opens=java.base/sun.security.provider=ALL-UNNAMED
--add-opens=java.base/sun.security.jca=ALL-UNNAMED
--add-opens=java.base/sun.reflect.generics.repository=ALL-UNNAMED
--add-opens=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED
--add-opens=java.base/sun.reflect.generics.tree=ALL-UNNAMED
--add-opens=java.base/sun.reflect.annotation=ALL-UNNAMED
--add-opens=java.base/sun.invoke.util=ALL-UNNAMED
--add-opens=java.xml.crypto/org.jcp.xml.dsig.internal.dom=ALL-UNNAMED
-XX:+UseJVMCINativeLibrary
-Xss10m
-Xms1g
-Xmx14g
-Duser.country=US
-Duser.language=en
-Djava.awt.headless=true
-Dorg.graalvm.version=21.1.0
-Dorg.graalvm.config=CE
-Dcom.oracle.graalvm.isaot=true
-Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader
-Xshare:off
--module-path
/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/truffle/truffle-api.jar
-Djdk.internal.lambda.disableEagerInitialization=true
-Djdk.internal.lambda.eagerlyInitialize=false
-Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false
-javaagent:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/svm.jar
-cp
/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/llvm-wrapper-shadowed.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/svm.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/objectfile.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/llvm-platform-specific-shadowed.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/javacpp-shadowed.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/svm-llvm.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/pointsto.jar
'com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus'
-imagecp
/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/library-support.jar:/Users/twolf/NetBeansProjects/graalBug/dist:/Users/twolf/NetBeansProjects/graalBug/dist/graalBug.jar
-H:Path=/Users/twolf/NetBeansProjects/graalBug/dist
-H:+ReportExceptionStackTraces
-H:FallbackThreshold=0
-H:+AllowIncompleteClasspath
-H:+DumpTargetInfo
'-H:Class@manifest from file:///Users/twolf/NetBeansProjects/graalBug/dist/graalBug.jar=com.spectare.gui.Startup'
'-H:Name@manifest from file:///Users/twolf/NetBeansProjects/graalBug/dist/graalBug.jar=graalBug'
-H:CLibraryPath=/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/clibraries/darwin-amd64
]
[graalBug:24051] classlist: 554.74 ms, 0.96 GB
[graalBug:24051] (cap): 1,622.55 ms, 0.96 GB
[graalBug:24051] setup: 2,707.38 ms, 0.96 GB
Building image for target platform: org.graalvm.nativeimage.Platform$DARWIN_AMD64
Using native toolchain:
Name: LLVM (clang)
Vendor: apple
Version: 13.0.0
Target architecture: x86_64
Path: /usr/bin/cc
Using CLibrary: com.oracle.svm.core.c.libc.NoLibC
[graalBug:24051] (clinit): 379.60 ms, 1.73 GB
Static libraries:
../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/clibraries/darwin-amd64/liblibchelper.a
../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libprefs.a
../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libnet.a
../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/clibraries/darwin-amd64/libdarwin.a
../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libnio.a
../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libjava.a
../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libfdlibm.a
../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libzip.a
../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/clibraries/darwin-amd64/libjvm.a
Other libraries: -framework Foundation,pthread,dl,z
[graalBug:24051] (typeflow): 5,489.06 ms, 1.73 GB
[graalBug:24051] (objects): 4,294.06 ms, 1.73 GB
[graalBug:24051] (features): 369.10 ms, 1.73 GB
[graalBug:24051] analysis: 10,810.42 ms, 1.73 GB
[graalBug:24051] universe: 559.96 ms, 1.73 GB
[graalBug:24051] (parse): 1,069.37 ms, 1.77 GB
[graalBug:24051] (inline): 1,367.76 ms, 2.43 GB
[graalBug:24051] (compile): 8,293.06 ms, 3.65 GB
[graalBug:24051] compile: 11,516.41 ms, 3.65 GB
[graalBug:24051] image: 1,655.90 ms, 3.65 GB
[graalBug:24051] write: 446.83 ms, 3.65 GB
Printing build artifacts to: graalBug.build_artifacts.txt
[graalBug:24051] [total]: 28,380.95 ms, 3.65 GB
twolf@MacBook-Pro dist % ./graalBug
Exception in thread "main" java.lang.UnsatisfiedLinkError: no awt in java.library.path
at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:132)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:47)
at java.lang.Runtime.loadLibrary0(Runtime.java:808)
at java.lang.System.loadLibrary(System.java:1893)
at java.awt.Toolkit$2.run(Toolkit.java:1385)
at java.awt.Toolkit$2.run(Toolkit.java:1383)
at java.security.AccessController.doPrivileged(AccessController.java:82)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1382)
at java.awt.Toolkit.(Toolkit.java:1415)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
at java.awt.EventQueue.invokeLater(EventQueue.java:1313)
at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1420)
at com.spectare.gui.Startup.main(Startup.java:7)
The text was updated successfully, but these errors were encountered: