Loading

Pages

Wednesday, September 19, 2012

Java Tutorial Part2 - Hello World

In comparison with some of the languages you may be familiar with, Java hello world needs more lines of code and would seem verbose.

Here is how we can print the customary "Hello World" in some scripting languages:

Ruby:
puts "Hello World";

PHP:
<?php 
 Print "Hello World";
?> 

Perl:
print "Hello World"; 

Python:
print "Hello World" 

Now, let us see the Java version.

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

}

Do the following steps to compile and run the Java version.

1)Type the above Java code in your favourite editor and save it as HelloWorld.java. This is our source file.

2)From command line/shell go to the folder where you saved the file and type
   javac HelloWorld.java.  A new file  HelloWorld.class is generated in the
  same folder as the source file.

3)Execute the program by entering  java HelloWorld at the command prompt.

You should be able to see the output now.

Java Tutorial Part1-Setting Up The Java Development Environment

This is the first step we need to take before starting on our journey. Set up the
Java Development Environment. Java programs run inside the
JVM(Java Virtual Machine). Java compiler(javac) converts Java programs into an
intermediate bytecode format called class files, which is platform independent.

The latest JDK can be downloaded from the following link:

Download the 32/62 bit version of the JDK for your OS(Linux, Windows or Mac) and follow the installation instructions .

Once the installation completes successfully, we are ready for the next step.

Tuesday, September 18, 2012

Java Tutorial -Introduction

You may be new to programming or you may already have some experience in scripting languages like Perl or PHP and want to learn an object oriented programming or you may be already familiar with C, C++ etc, and  now want to try  Java also- whatever be your background, we can help you. We will take you through a series of lessons on Java to give you a good understanding of the language. Let's get started with Part 1 .