SWT 3 and gcj

Rutger Ovidius ovid@mailandnews.com
Tue Oct 14 05:04:00 GMT 2003

Has anyone had success with SWT 3 and gcj?

Since SWT 2 has so many bugs, I would like to compile my application with SWT 
3.  I am attempting this on windows.

Eclipse Milestone 4 was recently released. SWT 3 from Milestone 4 is what I am 
using. (www.eclipse.org)

With gcj 3.3.1, I get many verification problems when trying to compile from 
the SWT.jar file (.class files).  When compiling from the source .java files, 
I eventually succeed in building a libswt.a file, if I remove some of the 
source files from the CLASSPATH and compile them from outside of the 
CLASSPATH. (I'm still not sure why this is necessary)

With the thisiscool 3.4 build: (gcc version 3.4 20031006 (experimental)), I 
less errors when compiling from .java source (only 2), but seemingly more 

./org/eclipse/swt/custom/StyledText.java:162: internal compiler error: tree 
check: expected class 'd', have 'x' (error_mark) in make_nested_class_name, at 

But, moving this file outside of the CLASSPATH and compiling it from there 
seems to work.

I use the build.sh from the thisiscool package for SWT building.

(gcj -fjni -c -o <all java files>, ar -rcs *.o libswt.a, ranlib libswt.a)

Once I create my libswt.a, I link my test app to it just as I do with SWT2.  
My SWT2 libswt.a works fine, but nothing I try with SWT3 will work.  Getting a 
simple Display fails.  (The swt-win32-3024.dll is in the same directory and is 
not the problem).

Exception in thread "main" java.lang.NullPointerException
   at __GLOBAL__I__ZN4Main4mainEP6JArrayIPN4java4lang6StringEE 

When I compile with "javac" and "java" run it, it works just fine with SWT3. 
Please let me know if you have had success with SWT3 and gcj. Thanks.


public class Main {
 public static void main( String[] args ) {
  Display display = new Display(  );
  Shell shell = new Shell( display );
  shell.setLayout( new FillLayout(  ) );
  shell.open(  );
  while ( !shell.isDisposed(  ) ) {
   if ( !display.readAndDispatch(  ) ) {
    display.sleep(  );

More information about the Java mailing list