Sunday, November 16, 2008

Getting Start

Welcome to javaFromBegining

Before start to learn Java, You should setup you'r computer so that a Java programme can be executed. For that, you should instal JDK on you'r machine. JDK can be downloaded from www.sun.java.com.
After you instal JDK, now it's time to setup the class path. Class path variable should set up to "BIN" derectory of java installation derectory. If you allowed to instal java in to it's default derectory, useually it instals in to "C:\Program Files" derectory. If so, the class path variable should set up to "C:\Program Files\Java\jdk1.5.0\bin" Location.

Now you are ready to start programming.
Let's start with a simple programme which is print a message to the console.
Code for a simple application can be done by using notepad or any text editor. But when you are moving to develop large application, it is hard to code with notepad. There are many tools to use for developments. Following tools are 2 from them

  • Netbeans

  • Eclips


I used Eclips for developments.
Following is the code sample for print a message to the console.

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

Now the source code should compile before it run. To do that, open the command prompt and move to the java source code derectory. After that type command "javac Helloworld.java" to compile.
Ex:-
C:Temp\> javac Helloworld.java
if there are no errors, You can run the programme by typing following code on command prompt.
"java Helloworld" and then it prints the Message you defined to print(Hello World)
Ex:-
C:\>java Helloworld
C:\>Hello World

No comments: