school assignment
Hello and thank you in advance,
My java text book supplies the following programming assignment:
Type in and run the following program:
import javax.swing.JOptionPane;
public class DialogTester
{
public static void main(String[] args)
{
JOptionPane.showMessageDialog(null, "Hello, World!");
System.exit(0);
}
}
So I type this into the compiler (BlueJ) editor and no errors occur. Then I right click on the class I created and select "static void main(String[] args)," which is supposed to run the program inside the terminal window in the compiler, but nothing happens.
Any ideas?
[665 byte] By [
datawerd2a] at [2007-11-26 16:47:04]

I guess You need not so fast CPU to see any thing ;))
Exit comes too fast for a human being...
Oh, yes. It is from book.
Make modiffications like this:
JOptionPane.showMessageDialog(null, "Hello, World!");
sleep(3000);
System.exit(0);
Message was edited by:
_Dima_
just execute java -cp . DialogTester from the command line in the directory where your .class file is located... Don't know how what you are doing, but I never heard of running a java program like that. Are you using an IDE or just some editor with command line?
@_Dima_ That's nonsense. System.exit(0) is only called after you close the dialog box.
JOptionPane.showMessageDialog(null, "Hello, World!"); is a blocking statement.
Message was edited by:
Peetzore
From the Javadoc:
All dialogs are modal. Each showXxxDialog method blocks the current thread until the user's interaction is complete.
It's quite logical since it is used for user interaction. You have to wait for user input before you can decide what to do next. This is quite a common concept in most languages.
So I tried running this program from the command prompt, in the directory where the files were created and compiled. I entered "java -cp.Dialogtester," only this time I received an error message: "Unrecognized option -cp.DialogTester
Could not create the Java virtual machine" I have JVM 6.0 and JDK 6.0 installed on my computer, using Windows XP. Whats next?
I think the book required by my university is a total piece of **** too.