Current location: Hot Scripts Forums » Programming Languages » Everything Java » Java Hello World example


Java Hello World example

Reply
  #1 (permalink)  
Old 08-25-10, 09:22 AM
Learnbyexamples Learnbyexamples is offline
Disabled
 
Join Date: Jun 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Platform and Technologies Take Center Stage at India’s No.1 Software Developer Conference wonkim785 JavaScript 0 04-17-10 01:39 AM
php & java is it right choice?? mif PHP 7 02-26-08 11:11 AM
The World Is Breathing Java! fouad Everything Java 16 08-19-03 05:53 PM


All times are GMT -5. The time now is 05:50 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.