Statically linking a Swing application
Shaun Jackman
sjackman@gmail.com
Thu Jan 26 10:45:00 GMT 2006
I statically linked a Swing "Hello, world!" application. Running the
resulting binary fails when trying to load the AWT peer:
$ ./Hello
Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit:
gnu.java.awt.peer.gtk.GtkToolkit
at java.awt.Toolkit.getDefaultToolkit (Unknown Source)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment (Unknown Source)
at java.awt.Window.<init> (Unknown Source)
at java.awt.Frame.<init> (Unknown Source)
at javax.swing.JFrame.<init> (Unknown Source)
at Hello.<init> (Unknown Source)
at Hello.main (Unknown Source)
Caused by: java.lang.ClassNotFoundException: gnu.java.awt.peer.gtk.GtkToolkit
at java.lang.Class.forName (Unknown Source)
at java.lang.Class.forName (Unknown Source)
at java.awt.Toolkit.getDefaultToolkit (Unknown Source)
...6 more
The AWT peer works fine when dynamically linked. When I strace the
binary, it finds the lib-gnu-java-awt-peer-gtk.so.7 library, mmaps,
and loads all its dependencies. It then closes the file descriptor,
munmaps everything it had just mmapped, and starts looking for
lib-gnu-java-awt-peer-gtk.so.7 in other places. Any suggestions why
dlopen doesn't seem to like lib-gnu-java-awt-peer-gtk.so.7? I'm using
GCJ 4.1.0 20060107 from Debian gcj-4.1 4.1-0exp6.
Many thanks!
Shaun
More information about the Java
mailing list