Home arrow Java & J2EE arrow Page 3 - Java Beginning Programming

Creating the Goodbye Cruel World application - Java

Since its creation about 16 years ago, Java has become ubiquitous. Developers appreciate its "write once, run anywhere" philosophy. If you want to start making use of Java and its many benefits, keep reading.

TABLE OF CONTENTS:
  1. Java Beginning Programming
  2. Terminology
  3. Creating the Goodbye Cruel World application
  4. Understanding the Code
By: James Payne
Rating: starstarstarstarstar / 17
September 18, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

To start, you will need to create a source file. Left-click on your Start menu and choose All Programs>Accessories>Notepad. When your document opens, type the following code:

Note: All code is case-sensitive, so be sure to type it in exactly as you see it.

/*
* This application will print the words “Goodbye Cruel World” across
* your monitor. Also note that these are just comments in your code
* for other programmers, and is invisible to the compiler.
*/

class GoodbyeCruelWorldApp {
  public static void main(String[] args) {
    System.out.println("Goodbye Cruel World!"); // Displays the string.
  }
}

Save the notepad file to your C: drive (it typically does not matter where you store the file. But in this case we will use your C: drive) under the name "GoodbyeCruelWorldApp.java", being sure to include the quotation marks. Then close your saved file.

Next we must change your source file into a .class File. To do this, left-click on your Start menu and choose the Run command. Type cmd into the pop-up box and press Enter. This will load the Command window, shown below:

 

In order to compile your Source File, you must change the directory to where your file is located. In the above example the prompt is set to your C: Drive. To change the directory, type cd C: and press Enter.

Next, to display the files within your C: Drive, type dir

You are now able to compile. In the prompt line type javac GoodbyeCruelWorldApp.java and press Enter.

If you type in dir again, you will see the new file, GoodbyeCruelWorldApp.class.

You are now ready to run your first program!

Running Your First Program

Without changing your directory, type java GoodbyeCruelWorldApp at the prompt.

This should display the text: “GoodbyeCruelWorld!” in the prompt window.



 
 
>>> More Java & J2EE Articles          >>> More By James Payne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: