Reputation: 55
I made a simple hello world program which just makes a window pop up with the title being "hello world". I want to know, What do I give to someone if I want them to run it like a normal java program? Would a .class file be enough?
do I just take the .class file and try to open it with java?
Here is the code:
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class hellobox {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello world!");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
I'm so sorry for such a pathetic question. first time fiddling with java.
Upvotes: 3
Views: 1157
Reputation: 8708
If you're using eclipse, you could do this:
That's it. Now you get a .jar
file which can be run like a normal executable file on every computer which has Java installed. Regardless of the operation system.
Just passing the .class
file would suffice, but it would force the other user to launch it via command line using java MyClassName
(without the .class suffix)
Upvotes: 1