From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.7) Gecko/20050416 Fedora/1.0.3-2 Firefox/1.0.3 Description of problem: Same as Bug 150453 - but I'm running fc4test2, either with or with the latest from development, I get an AWTError. The workaround supplied in the aforementioned closed bug works too. Version-Release number of selected component (if applicable): gcc-4.0.0-1 How reproducible: Always Steps to Reproduce: 1. Try to run AWT based java program Actual Results: [user@computer ~]$ java -cp `pwd` HelloAWT Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit at java.awt.Toolkit.getDefaultToolkit() (/usr/lib64/libgcj.so.6.0.0) at java.awt.EventQueue.invokeLater(java.lang.Runnable) (/usr/lib64/libgcj.so.6.0.0) ... Expected Results: [user@computer ~]$ java -cp `pwd` HelloAWT [user@computer ~]$ Additional info:
Are you sure you are using libgcj-4.0.0-1? With that and java-1.4.2-gcj-compat-1.4.2.0-40jpp_18rh it works just fine for me: import java.awt.*; import java.awt.event.*; class HelloAWT extends Frame { private static String message = "Hello AWT!"; HelloAWT() { super(message); } public void paint(Graphics g) { // get the windows width and height Dimension d = getSize(); // get the internal margins Insets i = getInsets(); // calculate the center point int cx = i.left + (d.width - i.left - i.right) / 2; int cy = i.top + (d.height - i.top - i.bottom) / 2; // get the attributes of the text FontMetrics fm = g.getFontMetrics(); // get the width of the message int width = fm.stringWidth(message); int height = fm.getHeight(); // draw the string g.drawString(message, cx - width / 2, cy + height / 2); } public static void main(String[] args) { // create the window Frame f = new HelloAWT(); // insert event handler for exiting the application f.addWindowListener( new WindowAdapter(){ public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setBounds(50, 50, 200, 200); f.show(); } } rpm -q gcc libgcj java-1.4.2-gcj-compat; java -cp `pwd` HelloAWT gcc-4.0.0-1 libgcj-4.0.0-1 java-1.4.2-gcj-compat-1.4.2.0-40jpp_18rh (.:16278): Gtk-WARNING **: cannot open display: (this is without X running, but from strace the Gtk peers are clearly loaded). gcc-4.0.0-1 certainly has the patch mentioned in 150453.
As sure as I can be... [user@computer ~]$ date Wed Apr 27 15:01:54 BST 2005 [user@computer ~]$ yum -e gcc (snip...) [user@computer ~]$ yum install gcc libgcj java-1.4.2-gcj-compat-devel (snip...) [user@computer ~]$ rpm -q gcc libgcj java-1.4.2-gcj-compat gcc-4.0.0-1 libgcj-4.0.0-1 java-1.4.2-gcj-compat-1.4.2.0-40jpp_18rh [user@computer ~]$ javac HelloAWT.java && java -cp `pwd` HelloAWT ---------- 1. WARNING in HelloAWT.java (at line 4) class HelloAWT extends Frame { ^^^^^^^^ The serializable class HelloAWT does not declare a static final serialVersionUID field of type long ---------- 1 problem (1 warning)Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit at java.awt.Toolkit.getDefaultToolkit() (/usr/lib64/libgcj.so.6.0.0) at java.awt.Window.getToolkit() (/usr/lib64/libgcj.so.6.0.0) at java.awt.Frame.addNotify() (/usr/lib64/libgcj.so.6.0.0) at java.awt.Window.show() (/usr/lib64/libgcj.so.6.0.0) at HelloAWT.main(java.lang.String[]) (Unknown Source) at .main (/usr/lib64/libgij.so.6.0.0) at .__libc_start_main (/lib64/libc-2.3.5.so) Caused by: java.lang.ClassNotFoundException: gnu.java.awt.peer.gtk.GtkToolkit not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/home/da/], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}} at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib64/libgcj.so.6.0.0) at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib64/libgcj.so.6.0.0) at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib64/libgcj.so.6.0.0) at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib64/libgcj.so.6.0.0) at java.awt.Toolkit.getDefaultToolkit() (/usr/lib64/libgcj.so.6.0.0) ...6 more [user@computer ~]$ export LD_LIBRARY_PATH=/usr/lib/gcc//x86_64-redhat-linux/4.0.0 [user@computer ~]$ java -cp `pwd` HelloAWT (success...)
Can you post e.g. strace output? I'm not alone who can't reproduce this problem.
Created attachment 113885 [details] Output from strace -f -v -o java.output java --cp $(pwd) HelloAWT Okay, attached is output from: $ strace -f -v -o java.output java --cp $(pwd) HelloAWT
FWIW I just deleted the entire partition and installed FC4test3: [da@testsys ~]$ rpm -q gcc libgcj java-1.4.2-gcj-compat gcc-4.0.0-2 libgcj-4.0.0-2 libgcj-4.0.0-2 java-1.4.2-gcj-compat-1.4.2.0-40jpp_18rh and I _still_ get the same problem. Would you like an strace of that, too?
I think libgcj is looking in /usr/lib for lib-gnu-java-awt-peer-gtk.so, when it should be looking in /usr/lib64. Jakub, this should be fixable in the libgcj RPM, right?
I'm seeing this type of problem with fc4t3 + may 23 updates. neuromancer> java -jar bin/rmmlite.jar Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit at java.awt.Toolkit.getDefaultToolkit() (/usr/lib64/libgcj.so.6.0.0) at java.awt.EventQueue.invokeLater(java.lang.Runnable) (/usr/lib64/libgcj.so.6.0.0) at javax.swing.SwingUtilities.invokeLater(java.lang.Runnable) (/usr/lib64/libgcj.so.6.0.0) at javax.swing.RepaintManager.addInvalidComponent(javax.swing.JComponent) (/usr/lib64/libgcj.so.6.0.0) at javax.swing.JComponent.revalidate() (/usr/lib64/libgcj.so.6.0.0) at javax.swing.JComponent.setOpaque(boolean) (/usr/lib64/libgcj.so.6.0.0) at javax.swing.JPanel.JPanel(java.awt.LayoutManager, boolean) (/usr/lib64/libgcj.so.6.0.0) at javax.swing.JRootPane.createGlassPane() (/usr/lib64/libgcj.so.6.0.0) at javax.swing.JRootPane.getGlassPane() (/usr/lib64/libgcj.so.6.0.0) at javax.swing.JRootPane.JRootPane() (/usr/lib64/libgcj.so.6.0.0) at javax.swing.JFrame.createRootPane() (/usr/lib64/libgcj.so.6.0.0) at javax.swing.JFrame.getRootPane() (/usr/lib64/libgcj.so.6.0.0) at javax.swing.JFrame.frameInit() (/usr/lib64/libgcj.so.6.0.0) at javax.swing.JFrame.JFrame(java.lang.String) (/usr/lib64/libgcj.so.6.0.0) at com.rio.rmmlite.ChooseRmmlOrTaxi.main(java.lang.String[]) (Unknown Source) at .main (/usr/lib64/libgij.so.6.0.0) at .__libc_start_main (/lib64/libc-2.3.5.so) Caused by: java.lang.ClassNotFoundException: gnu.java.awt.peer.gtk.GtkToolkit not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:bin/rmmlite.jar,file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}} at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib64/libgcj.so.6.0.0) at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib64/libgcj.so.6.0.0) at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib64/libgcj.so.6.0.0) at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib64/libgcj.so.6.0.0) at java.awt.Toolkit.getDefaultToolkit() (/usr/lib64/libgcj.so.6.0.0) ...16 more neuromancer>
I got the same error as you. But now I can compile and run java awt program after I ran this command: ln -s gcc/x86_64-redhat-linux/4.0.0/lib-gnu-java-awt-peer-gtk.so /usr/lib/ Will this could be a hint? os: fc4 x86-64 gcc(gcj): 4.0.0-8
I deleted FC4test3 and install FC4 as released, installed on a fresh partition. I get the same problem, $ rpm -q gcc libgcj java-1.4.2-gcj-compat gcc-4.0.0-8 libgcj-4.0.0-8 libgcj-4.0.0-8 java-1.4.2-gcj-compat-1.4.2.0-40jpp_31rh I did another strace -f, it appears to me that when it comes to opening lib-gnu-java-awt-peer-gtk.so, it is looking in /usr/lib, and trying to load the 32-bit version, then failing. Successfully loaded libs are being looked for in /usr/lib64... Here's an excerpt from the trace, if it helps: 6907 access("/usr/lib/lib-gnu-java-awt-peer-gtk.so.6", R_OK) = 0 6907 access("/usr/lib/lib-gnu-java-awt-peer-gtk.so.6", R_OK) = 0 6907 open("/usr/lib/lib-gnu-java-awt-peer-gtk.so.6", O_RDONLY) = 13 6907 read(13, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0000y\3\000"..., 640) = 640 6907 close(13) = 0 6907 open("/lib/lib-gnu-java-awt-peer.la", O_RDONLY) = -1 ENOENT (No such file or directory) This seems to be where the trouble starts.
Should be fixed in libgcj-4.0.0-13 in rawhide. As a workaround, you can run the Java programs with LD_LIBRARY_PATH=/usr/lib64
*** Bug 163671 has been marked as a duplicate of this bug. ***