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.
If you’re using eclipse, you could do this:
project or class that contains the main method
That’s it. Now you get a
.jarfile which can be run like a normal executable file on every computer which has Java installed. Regardless of the operation system.Just passing the
.classfile would suffice, but it would force the other user to launch it via command line usingjava MyClassName(without the .class suffix)