Home Java Beginners Hello world (First java program)
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Hello world (First java program)

Advertisement
Hello world program is the first step of java programming language. Be careful when you write the java code in your text pad because java is a case sensitive programming language.

Hello world (First java program)

     

Java is a high level programming language and it is used to develop the robust application. Java application program is platform independent and can be run on any operating System. Writing Hello World program is very simple. To write the Hello world program you need  simple text editor like note pad and  jdk must be install in your machine for compiling and running. Hello world program is the first step of java programming  language. Be careful when you write the java code in your text pad because java is a case sensitive programming language.

 For Example

hello world   !=(not equal to) Hello World

Write the following code into your note pad to run the Hello World program .

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

Save the file and Please remember the location where you save your file. In this example we have saved the file in the "C:\javatutorial\example" directory. The file name should be match the class name and to save the file give the .java extension. e.g.  HelloWorld.java

Now open the command prompt to compile the HelloWorld.java program. Go to the directory where you have saved the file ( in our case C:\javatutorial\example>) and issue the following command to compile the program:

C:\javatutorial\example>javac HelloWorld.java

javac is a compiler in the java Language. Java compiler change the programming Language into machinery language. So that the java virtual can understand it. Once the compilation is successful a new file will be created with the name HelloWorld.class.  To run the program issue the following command on command prompt:

C:\javatutorial\example>java HelloWorld

You will see the following result on the command prompt.

Hello World!

Here is the screen shot of the above steps:

In this lesson you have learned how to write and then test the Hello World! java program.

 

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 1, 2007

Ask Questions?    Discuss: Hello world (First java program)   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
ee
September 5, 2011
learn java

i want learn java
Keith Harryman
June 1, 2013
running HelloWorld.java

when I run, I get: "Error: Could not find or load main class HelloWorld" but it did create the HelloWorld.class file in the same directory.
arun aggarwal
September 28, 2011
oot

java programming
Akshay Prabhu
November 29, 2011
Regards

Nice ! to see a Tutorial !,hmmmm just goin through still Hello Java ,will give my opinions ,once i go further !
SAJID PATEL
January 18, 2012
about hello world program in roseindia

this site is useful for new java users...i like it......
khasim
January 23, 2012
java

what is the coding
mamatha
February 22, 2012
to see the output

How to see the output of the java program without Dos prompt. kindly help me
what is the meaning of System,String?
February 23, 2012
question

plz tell the answer of the above question asap
Dantreliya Sanjay h
March 16, 2012
java

i receive to all the information to send my email to any java markets
Bashir
March 24, 2012
java error

I get the error "unable to launch application" and on going to details it says " could not parse launch file.error at line 0" please help
Shiva kumar
June 28, 2012
pls send clarifications about these topics

class HelloWorld { == why we use this class and when? where? public static void main(String[] args){ === void main use ? System.out.println("Hello World!"); === system out use? } } because i don't know even basics also, c, c++, also don't know
Swathy Edayath
September 11, 2012
It was helpful

Thank You..
jaz
August 18, 2013
java

Its a very good website .its really helps me im my studies... I
linu
February 7, 2014
java

i want for loop examplesin different logic
DMCA.com