I created a Hello World SWT application using Eclipse and I was able to run it from Eclipse (everything works fine). But I wonder how other peoples (users) will run this kind of application. Should they install Eclipse, import my project and run it? It sounds strange.
A:
You have to run the class file with the main method. example: java testMain.class
maybe you have to specify a classpath
u2ix
2010-02-17 10:34:31
Do you mean that I can ran *.class file, generated by Eclipse, by typing "java className.class" in the command line? I tired that and it did not work.
Roman
2010-02-17 10:39:12
yes, that's what he meant. But you need to be in the right working directory and in case your class is not in the default package you need to specify your package, too. E.g. `java com.mypackage.className.class`
Stroboskop
2010-02-17 10:49:20
@u2ix, @Stroboskop: you never specify the `.class` on the `java` command line.
Joachim Sauer
2010-02-17 12:26:37
@Roman: please define "did not work". What error did you get? You must have SWT on the classpath of course.
Joachim Sauer
2010-02-17 12:27:03
+3
A:
This should help :
http://wiki.eclipse.org/FAQ_How_do_I_create_an_executable_JAR_file_for_a_stand-alone_SWT_program%3F
phtrivier
2010-02-17 10:48:27
A:
If you are delivering it to somebody else, then you have to create an executable jar, with mentioning your main class(ie a public class with main() method in it) in the jar's manifest file as the Main-Class. So when prople double click it or type: jar "your jar name" in command console then they will get it executed.
GK
2010-02-17 12:24:51
This is generally true of Java - but since this is SWT - he'll also need to handle packaging / providing the native SWT libraries.
Nate
2010-02-17 13:40:26