9/03/2013

How To Run A Simple Java Program To Display A Message In A Dialog Box

How To Run A Simple Java Program To Display A Message In A Dialog Box

Head First Java 2nd Edition Book Kindle And Paperback First, if you're new to Java check out my Java Tutorials to get started!

If you've gotten the basics down, but need to know how to run a java program in command prompt check out:

>>> How To Use Command Prompt To Run A Simple Java Program

If you're ready for this tutorial, let's begin!

The Tutorial:

Open up Text Editor on your computer.

To do this, right click your desktop screen and select New, then select Text Document

Change the name of the file to WelcomeToJavaDialogBox.java

Enter the program code below in to the Text Editor

import javax.swing.*;
public class WelcomeToJavaDialogBox {
  public static void main(String[] args) {
     String st="Welcome To Java";
     JOptionPane.showMessageDialog(null,st);
  }
}

Now Save your file!

Let's compile the program!

Open up Command Prompt and type in javac WelcomeToJavaDialogBox.java

If the program has no errors and compiled it should look like this:

Tutorial One How To Run A Simple Java Program To Display A Message In A Dialog Box


Now let's run the program and display the message!

in the Command Prompt type in java WelcomeToJavaDialogBox

Now it will display this:

Tutorial Two How To Run A Simple Java Program To Display A Message In A Dialog Box


Success you're done!

No comments:

Post a Comment


Copyright © justinwoodie.com ©