Java
  Home arrow Java arrow Page 3 - Java Beginning Programming
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
JAVA

Java Beginning Programming
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 16
    2007-09-18


    Table of Contents:
  • Java Beginning Programming
  • Terminology
  • Creating the Goodbye Cruel World application
  • Understanding the Code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Java Beginning Programming - Creating the Goodbye Cruel World application
    ( Page 3 of 4 )

    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 Articles          >>> More By James Payne
     

       

    JAVA ARTICLES

    - Exception Handling Techniques in Java
    - More About Multithreading in Java
    - The Basics of Multiple Threads in Java
    - Data Access Using Spring Framework JDBC
    - New Object Initialization in Java
    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek