problem embedding resources

Camilla Orlandi corlandi@land.it
Thu Oct 20 15:01:00 GMT 2005


Andrew Haley ha scritto:

>If you give us an example we can reproduce, with the commands and the
>files you use, we could help yopu.
>
>OK, you don't have to attach the GIF; we can make one ourselves.  But
>you do have to attach all the source code and all the commands.
>
>Andrew.
>  
>
ok, sorry, here is the HelloWorld.java code:


*********************************

package ex;

import org.eclipse.swt.widgets.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;

public class HelloWorld {
   
    public HelloWorld(){
   
        Display d=new Display();
        Shell s=new Shell(d);
        s.setSize(100,200);
       
        Label aLabel=new Label(s, SWT.BORDER);
        aLabel.setBounds(0,0,100,100);
        aLabel.setImage(
                new Image(d,
            HelloWorld.class
            .getResourceAsStream("swt.gif")));
       
        s.open();
       
        while(!s.isDisposed()){
            if(!d.readAndDispatch()){
                d.sleep();
            }
        }
       
        d.dispose();
    }
   
    public static void main(String[] args){
        HelloWorld hw=new HelloWorld();
    }
   
}

*********************************

commands:

gcj -c -o swigtif.o --resource=swt.gif swt.gif

gcj -s -fjni --main=ex.HelloWorld -s -o HelloWorld.exe 
ex/HelloWorld.java swtgif.o



using the same code, not includeing it in the ex package, it's ok.
thanks

Camilla




More information about the Java mailing list