Make SWT/Jface application outside of Eclipse [message #212004] |
Thu, 24 May 2007 21:18 |
Eclipse User |
|
|
|
Originally posted by: agent_tony_smith.hotmail.com
Hi,
Sorry I'm a beginner with both Eclipse and Java (especially when it comes
to compiling and running programs, not so much the programing itself).
I designed a dummy SWT application (see code at the end). I can run it
just fine in Eclipse. What I'd like to be able to do now is run it outside
of the context of Eclipse, like just clicking on an icon and see my
program pop up and disappear when I want it to close.
I tried to write a little script that does this:
java -cp " /home/tomcat/Desktop/swt-M20070212-1330-gtk-linux-x86/swt.ja r;. "
Hello2
I get:
Exception in thread "main" java.lang.NoClassDefFoundError: Hello2
though:
[tomcat@m8 bin]$ ls -l
total 36
-rw-rw-r-- 1 tomcat tomcat 934 May 24 17:09 Hello2$1.class
-rw-rw-r-- 1 tomcat tomcat 1660 May 24 17:09 Hello2.class
...
Does anybody know what I should do? I guess I should create a jar or
something but again, not very familiar with all this ^_^
Thanks!
-------------------------------------------
Dummy application:
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class Hello2 {
public static Display display ;
public static Shell shell;
public static Label label;
public static Button submit;
public static int i=0;
/**
* @param args
*/
public static void main(String[] args) {
display = new Display();
shell = new Shell (display);
shell.setLayout(new RowLayout());
label = new Label (shell, 0);
label.setText("nothing");
submit = new Button (shell, 1 << 3);
submit.setText("Submit");
i=0;
submit.addSelectionListener ( new SelectionAdapter() {
public void widgetSelected (SelectionEvent e) {
String s = i + "";
label.setText( s );
i++;
}
});
shell.setSize(500, 500);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
label.dispose();
shell.dispose();
submit.dispose();
}
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08938 seconds