Bug 159295 - awt and swing Exceptions in gcc 4.0 Redhat Linux 9.0
awt and swing Exceptions in gcc 4.0 Redhat Linux 9.0
Status: CLOSED WORKSFORME
Product: Fedora
Classification: Fedora
Component: gcc4 (Show other bugs)
4
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-06-01 11:20 EDT by ahmad bilal hasan
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-06-01 11:27:51 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description ahmad bilal hasan 2005-06-01 11:20:42 EDT
Description of problem:
hi, i have redhat linux 9.0 installed(everything) in my pc, and i installed
gcc4.0, but when i complied the java program from deitel&deitel it throws
exceptions,


[root@dsn-bilal java test]# ./PopupTest
Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit:
   at java.awt.Toolkit.getDefaultToolkit() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at java.awt.EventQueue.invokeLater(java.lang.Runnable)
(/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.SwingUtilities.invokeLater(java.lang.Runnable)
(/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.RepaintManager.addInvalidComponent(javax.swing.JComponent)
(/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JComponent.revalidate() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JComponent.setOpaque(boolean) (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JPanel.JPanel(java.awt.LayoutManager, boolean)
(/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JPanel.JPanel() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JRootPane.createGlassPane() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JRootPane.getGlassPane() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JRootPane.JRootPane() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JFrame.createRootPane() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JFrame.getRootPane() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JFrame.frameInit() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JFrame.JFrame(java.lang.String) (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at PopupTest.PopupTest() (/root/java test/PopupTest.java:13)
   at PopupTest.main(java.lang.String[]) (/root/java test/PopupTest.java:67)
   at gnu.java.lang.MainThread.call_main() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at gnu.java.lang.MainThread.run() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
Caused by: java.lang.ClassNotFoundException:
   at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader)
(/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at java.lang.Class.forName(java.lang.String) (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at java.awt.Toolkit.getDefaultToolkit() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   ...18 more
[root@dsn-bilal java test]#


i have installed gcc4.0 in /opt/gcc4.0 directory and i have checked its paths
using $PATH and $LD_LIB_PATH variables, i have previously installed gcc3.2.2 i
dont know what to do, please tell me step by step to resolve it, i dont know
weather any body have executed any swing program on gcc4.0 or not,



Version-Release number of selected component (if applicable):


How reproducible:
here is the java file

// Fig. 13.8: PopupTest.java
// Demonstrating JPopupMenus
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class PopupTest extends JFrame {
   private JRadioButtonMenuItem items[];
   private Color colorValues[] = 
      { Color.blue, Color.yellow, Color.red };

   public PopupTest()
   {
      super( "Using JPopupMenus" );

      final JPopupMenu popupMenu = new JPopupMenu();
      ItemHandler handler = new ItemHandler();
      String colors[] = { "Blue", "Yellow", "Red" };
      ButtonGroup colorGroup = new ButtonGroup();
      items = new JRadioButtonMenuItem[ 3 ];

      // construct each menu item and add to popup menu; also
      // enable event handling for each menu item
      for ( int i = 0; i < items.length; i++ ) {         
         items[ i ] = new JRadioButtonMenuItem( colors[ i ] );
         popupMenu.add( items[ i ] );
         colorGroup.add( items[ i ] );
         items[ i ].addActionListener( handler );                
      }

      getContentPane().setBackground( Color.white );

      // define a MouseListener for the window that displays
      // a JPopupMenu when the popup trigger event occurs
      addMouseListener(
         new MouseAdapter() {
            public void mousePressed( MouseEvent e )
               { checkForTriggerEvent( e ); } 

            public void mouseReleased( MouseEvent e )
               { checkForTriggerEvent( e ); } 

            private void checkForTriggerEvent( MouseEvent e )
            {
               if ( e.isPopupTrigger() ) 
                  popupMenu.show( e.getComponent(),
                                  e.getX(), e.getY() );               
            }
         }
      );    

      setSize( 300, 200 );
      show();
   }

   public static void main( String args[] )
   {
      PopupTest app = new PopupTest();

      app.addWindowListener(
         new WindowAdapter() {
            public void windowClosing( WindowEvent e )
            {
               System.exit( 0 );
            }
         }
      );
   }

   private class ItemHandler implements ActionListener {
      public void actionPerformed( ActionEvent e )
      {
         // determine which menu item was selected
         for ( int i = 0; i < items.length; i++ )
            if ( e.getSource() == items[ i ] ) {
               getContentPane().setBackground(
                  colorValues[ i ] );
               repaint();
               return;
            }
      }
   }
}

/**************************************************************************
 * (C) Copyright 1999 by Deitel & Associates, Inc. and Prentice Hall.     *
 * All Rights Reserved.                                                   *
 *                                                                        *
 * DISCLAIMER: The authors and publisher of this book have used their     *
 * best efforts in preparing the book. These efforts include the          *
 * development, research, and testing of the theories and programs        *
 * to determine their effectiveness. The authors and publisher make       *
 * no warranty of any kind, expressed or implied, with regard to these    *
 * programs or to the documentation contained in these books. The authors *
 * and publisher shall not be liable in any event for incidental or       *
 * consequential damages in connection with, or arising out of, the       *
 * furnishing, performance, or use of these programs.                     *
 *************************************************************************/



Steps to Reproduce:
1. gcj -c -g -O PopupTest.java
2.gcj --main=PopupTest -o PopupTestPopupTest.o
3. ./PopupTest
  
Actual results:
[root@dsn-bilal java test]# ./PopupTest
Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit:
   at java.awt.Toolkit.getDefaultToolkit() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at java.awt.EventQueue.invokeLater(java.lang.Runnable)
(/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.SwingUtilities.invokeLater(java.lang.Runnable)
(/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.RepaintManager.addInvalidComponent(javax.swing.JComponent)
(/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JComponent.revalidate() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JComponent.setOpaque(boolean) (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JPanel.JPanel(java.awt.LayoutManager, boolean)
(/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JPanel.JPanel() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JRootPane.createGlassPane() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JRootPane.getGlassPane() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JRootPane.JRootPane() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JFrame.createRootPane() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JFrame.getRootPane() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JFrame.frameInit() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at javax.swing.JFrame.JFrame(java.lang.String) (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at PopupTest.PopupTest() (/root/java test/PopupTest.java:13)
   at PopupTest.main(java.lang.String[]) (/root/java test/PopupTest.java:67)
   at gnu.java.lang.MainThread.call_main() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at gnu.java.lang.MainThread.run() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
Caused by: java.lang.ClassNotFoundException:
   at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader)
(/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at java.lang.Class.forName(java.lang.String) (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   at java.awt.Toolkit.getDefaultToolkit() (/opt/gcc4.0/lib/libgcj.so.6.0.0)
   ...18 more
[root@dsn-bilal java test]#



Expected results:


Additional info:
Comment 1 Jakub Jelinek 2005-06-01 11:27:51 EDT
And why are you reporting it here?  If you can reproduce it on Fedora Core 4,
it is supposed to be reported here, but this very much sounds like a gcc
configuration problem on your side.  Works just fine here.
EIther you have not configured the Gtk peers in, or libgcj is not able to find
that shared library.

Note You need to log in before you can comment on or make changes to this bug.