faqts : Computers : Programming : Languages : Java

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 9 people (44%) answered Yes
Recently 4 of 9 people (44%) answered Yes

Entry

Java: Application: Create: Simple: How to create a stand alone program that displays 'Hello World'?

May 25th, 2006 17:54
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 07 September 2003 - 04:24 am ------------------

Java: Application: Create: Simple: How to create a stand alone program 
that displays 'Hello World'?

---

Steps: Overview:

 1. Type the program in your favorite text editor

 class HelloWorld {
  public static void main( String args[] ) {
   System.out.println( "Hello World" );
  }
 }

 2. Your program should so contain the 'main' method

 3. Save this file with extension .java

     e.g.

      HelloWorld.java

 4. Compile with

     javac.exe HelloWorld.java

 5. If compiled successfully this will create
    (in the same directory) a file:

     HelloWorld.class

 6. Run with

     java.exe HelloWorld

 7. That will show on the console command line:

     Hello World

---

Here a typical screen output:

+---------------------------------------+
|                                       |
|javac.exe HelloWorld.java              |
|                                       |
|java.exe -classpath . HelloWorld       |
|                                       |
|Hello World                            |
|                                       |
+---------------------------------------+

---

Internet: see also:

---

Java: Class: Create: Simple: How to create a class in Java?
http://www.faqts.com/knowledge_base/view.phtml/aid/24842/fid/165

---

Java: Compile: Error: Exception in thread "main" 
java.lang.NoClassDefFoundError: HelloWorld
http://www.faqts.com/knowledge_base/view.phtml/aid/24300/fid/165

---

Java: Tutorial: Joe Grip
http://www.joegrip.com/seeit.html

----------------------------------------------------------------------