[fedora-java] Compiling a basic SWT app on FC4

Ryan McDougall NQG24419 at nifty.com
Fri Jul 15 09:04:39 UTC 2005


I apologize if this question is too low level for this list, but I've
spend the entire afternoon googling to no avail.

I am trying to compile a simple SWT app using either Sun's Java or GCJ
(preferably both) on my FC4 system. If I am successful at this (and the
process is indeed complex), I don't mind writing up a tutorial for the
Wiki or some such, in return.

I have gcj and eclipse installed, as well as Sun's 1.5 JDK (java and
javac are currently linked to Suns JVM, but I can change that back).
short. 

Here are the current rpms that are relevant:
libswt3-gtk2-3.1.0_fc-0.M6.22
libgcj-4.0.0-8
gcc-java-4.0.0-8
java-1.4.2-gcj-compat-devel-1.4.2.0-40jpp_31rh
java-1.4.2-gcj-compat-1.4.2.0-40jpp_31rh

Here is the simple app source in a file called TestGui.java:

import org.eclipse.swt.*;

public class TestGui
{
   public static void main (String [] args) {
	      Display display = new Display ();
	      Shell shell = new Shell (display);
	      Label label = new Label (shell, SWT.CENTER);
	      label.setText ("Hello_world");
	      label.setBounds (shell.getClientArea ());
	      shell.open ();
	      while (!shell.isDisposed ()) {
	         if (!display.readAndDispatch ()) display.sleep ();
	      }
	      display.dispose ();
	   }
}

I have tried the following commands based on guesses based on online
tutorials:

$ gcj
--classpath=/usr/share/eclipse/plugins/org.eclipse.swt.gtk_3.1.0.jar /usr/lib/eclipse/plugins/org.eclipse.swt.gtk_3.1.0.jar.so --main=TestGui TestGui.java -o Test

Running Test gives me the following error:

Exception in thread "main" java.lang.LinkageError: unexpected exception
during linking: org.eclipse.swt.widgets.Display
   at java.lang.VMClassLoader.transformException(java.lang.Class,
java.lang.Throwable) (/usr/lib/libgcj.so.6.0.0)
   at java.lang.VMClassLoader.resolveClass(java.lang.Class)
(/usr/lib/libgcj.so.6.0.0)
   at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.6.0.0)
   at TestGui.main(java.lang.String[]) (Unknown Source)
   at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
   at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
Caused by: java.lang.NullPointerException
   at java.lang.VMClassLoader.resolveClass(java.lang.Class)
(/usr/lib/libgcj.so.6.0.0)
   ...4 more

I also tried:
$ javac
-classpath /usr/share/eclipse/plugins/org.eclipse.swt.gtk_3.1.0.jar
TestGui.java 
$ java
-Djava.library.path=/usr/lib/eclipse/plugins/org.eclipse.swt.gtk_3.1.0.jar.so TestGui 

With the result being:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/swt/widgets/Composite

But I don't expect you to help me out with a propriety thing. :)

Thank you for your time and effort!

Cheers,
Ryan




More information about the fedora-devel-java-list mailing list