Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2010, 09:36 AM
EliteHussar
Guest
 
Posts: n/a
Default Java Hello World example

Learning by examples
Hello World is a classic sample to start when we learn a new programming language. Below is the Java version of Hello World program, it simple enough to start.

Code:
public class HelloWorld  
{  
    public static void main(String[] args)  
    {  
        // say hello to the world  
        System.out.println("Hello World!");  
    }  
}
The code contains one class called HelloWorld, a main(String[] args) method which is the execution entry point of every Java application and a single line of code that write a Hello World string to the console. That’s all, we are done!
To run the application we need to compile it first. I assume that you have your Java in your path. To compile it type
Code:
% javac HelloWorld.java
The compilation process will result a file called HelloWorld.class, this is the binary version of our program. As you can see that the file ends with .class extension because Java is everyting about class.
To run it type the command bellow, class name is written without it extension.

Java Hello World example





Similar Threads
Thread Thread Starter Forum Replies Last Post
hello world! help :( archer11 BOOK: Beginning iPad Application Development 11 August 24th, 2010 01:27 PM
Chapter 2: Hello World londo-cat BOOK: Beginning iPhone SDK Programming with Objective-C 1 July 12th, 2010 07:09 PM
Hello World Example Chapter 1 goboomer BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 12 January 14th, 2009 10:07 PM
GRPS "Hello World" rodmcleay C# 0 October 11th, 2005 10:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.