Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Training First Java Program

Related Tutorials


 
 

Share on Google+Share on Google+

First Java Program

Advertisement
Here you will find the video tutorial for creating first Java program. You can learn through video tutorial of Java.

Welcome to java tutorial series. In this lesson, you will learn to create your first Java program.

In Java, all source code is written in plain text file which is saved as .java file. The Java compiler is use to compile the source code (.java file) into binary file with .class extension. On the command prompt the javac command is used to invoke the Java compiler. This .class file does not contain code that is native to your processor; instead it contains a byte code that is converted into machine specific binary code by the Java Virtual Machine.

You can write a Hello World program as your first Java program. To write the Hello world program you need simple text editor like note pad and make sure the JDK is already installed on your machine for compiling and running that program.

Here is the complete video tutorial.

Write the following code, given on the screen, on your note pad to and save as HelloWorld.java file.

Here is the complete code of the HelloWorld.java program.

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

You can save the above file in java file e.g. HelloWorld.java in any drive of your hard disk.

Save the file and remember the location where you save your file. In this example we have saved the file in the C:\javatutorial\example directory. Save the file with .java extension. e.g. HelloWorld.java.

Using javac, you can compile the Java source code into byte code and using java command, you can interpret and run the program as shown on your screen.

After compiling the program it generates the .class file. In our case HelloWorld.class will be generated. You can execute the file using java HelloWorld command.

You should open the command prompt and go to the directory where java is saved. To compile use the java HelloWorld.java command and to execute the program use java HelloWorld command.

Go to the Java video tutorial index page for more video tutorials.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



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 11, 2013

Related Tutorials

Discuss: First Java Program  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com