You are not logged in.

#1 2006-12-04 01:37:58

iggy
Member
From: Germany, L.E. - Leipzig
Registered: 2004-10-17
Posts: 367

running swt-apps without eclipse

hello!

i want to learn more about java and guis and so i decided to take a look at swt. here is my first try, only to test something.
i can compile it, but when i want to run it i get the following error-message:

$ export CLASSPATH=".:/opt/eclipse/plugins/org.eclipse.swt.gtk.linux.x86_3.2.1.v3235.jar"
$ javac View.class
$ java View
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3235 in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
        at java.lang.Runtime.loadLibrary0(Runtime.java:822)
        at java.lang.System.loadLibrary(System.java:993)
        at org.eclipse.swt.internal.Library.loadLibrary(Library.java:123)
        at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:22)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
        at org.eclipse.swt.widgets.Display.<clinit>(Display.java:126)
        at org.eclipse.swt.widgets.Widget.isValidSubclass(Widget.java:867)
        at org.eclipse.swt.widgets.Decorations.checkSubclass(Decorations.java:162)
        at org.eclipse.swt.widgets.Shell.<init>(Shell.java:248)
        at org.eclipse.swt.widgets.Shell.<init>(Shell.java:243)
        at org.eclipse.swt.widgets.Shell.<init>(Shell.java:197)
        at org.eclipse.swt.widgets.Shell.<init>(Shell.java:136)
        at View.<init>(View.java:27)
        at View.main(View.java:61)

here is my java-code:

import java.io.BufferedReader;
import java.io.InputStreamReader;

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;

public class View {

    private Shell sShell = null;
    private Text text = null;
    private Button bExec = null;
    private Button bCancel = null;

    /**
     * This method initializes sShell
     */
    public View() {
        sShell = new Shell();
        sShell.setText("Shell");
        sShell.setSize(new Point(300, 200));
        sShell.setLayout(null);
        text = new Text(sShell, SWT.BORDER);
        text.setBounds(new Rectangle(45, 3, 200, 23));
        bExec = new Button(sShell, SWT.NONE);
        bExec.setBounds(new Rectangle(170, 145, 75, 27));
        bExec.setText("Execute");
        bExec.addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
            public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
                try {
                    Runtime rt = Runtime.getRuntime();
                    Process proc = rt.exec(text.getText());
                    BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
                    while(br.ready())
                    {
                        System.out.println(br.readLine());
                    }
                } catch(Exception foo) {}
            }
        });
        bCancel = new Button(sShell, SWT.NONE);
        bCancel.setBounds(new Rectangle(45, 145, 75, 27));
        bCancel.setText("Cancel");
        bCancel.addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
            public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
                System.exit(1);
                System.out.println("Goodbye...");
            }
        });
    }

    public static void main(String args[]) {
        View v = new View();
    }
    
}

how i can realize it, to run such programs without doing it with eclipse!

thx, mfg
iggy


sorry for my bad english smile

Offline

#2 2006-12-08 06:28:44

dr_te_z
Member
From: Zoetermeer, the Netherlands
Registered: 2006-12-06
Posts: 154

Re: running swt-apps without eclipse


Somewhere between "too small" and "too large" lies the size that is just right.
- Scott Hayes

Offline

Board footer

Powered by FluxBB