Re: [javaCompiler-users] Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit
Status: Beta
Brought to you by:
soapy
From: Marco T. <mt...@gm...> - 2006-08-20 11:52:51
|
Hello Stephen First of all, AWT and Swing is not ready for real applications. There are two possibilities for it right now: - swingWT; it maps AWT and Swing to SWT. A lot is still missing here until it's complete... But it's open source, you can enhance it to support all your needed stuff. - AWT/Swing from gnu classpath (used by gcj). On linux it works only for shared applications, not for static. On windows it doesn't work at all. swingWT is currently the better choice... If you create a managed AWT or Swing project, this will be used. If you create a unmanaged project, the classpath AWT/Swing classes will be used (but because javaCompiler only creates static applications, this will fail anyway). Now, after that intro, lets take a look at your problem: > I tried it out an a game I've written in Java, that uses the > java.awt.Graphics2D stuff fairly heavily, along with BufferedImage > objects, but no AWT widgets or anything. Ok, then you might use external libraries to bypass the current AWT/Swing problems... > After building a windows .exe from my jar file (thats classes, not > source), I get the following error when running it: > > Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: > gnu.java.awt.peer.gtk.GtkToolkit > at java.awt.Toolkit.getDefaultToolkit(game-win.exe) > at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment > (game-win.exe) > at java.awt.Window.<init>(game-win.exe) > at java.awt.Frame.<init>(game-win.exe) > at java.awt.Frame.<init>(game-win.exe) > at com.longsteve.GameFrame.<init>(game-win.exe ) > at com.longsteve.Game(game-win.exe) > Caused by: java.lang.ClassNotFoundException: > gnu.java.awt.peer.gtk.GtkToolkit not found in > gnu.gcj.runtime.SystemClassLoader{urls=[file:.\], > parent=gnu.gcj.runtime.ExtensionClassLoader{urls= [], parent=null}} > at java.lang.Class.forName(game-win.exe) > at java.awt.Toolkit.getDefaultToolkit(game-win.exe) > ...6 more That's the error message when using AWT/Swing from gnu classpath. Even on a simple hello world programm that uses java.awt.Dimension, the whole AWT toolkit will be loaded (what fails with this message)... > I used "Managed AWT or Swing project" to start with. Shure? That would mean that my adaptions of the classes fail on some points and gnu classpath is used instead of swingWT... Or did you use a jar? Classes in a jar are not preprocessed for swingWT... If you used a jar, unpack your classes and try with them. With luck, swingWT covers all your requirements. If you used classes directly, please use the source and try again. If it works, I'd be interested in the class that wasn't adapted for swingWT. Maybe you can find it... regards Marco |