STARTING DAY

WELCOME TO JAVA


This is java Sample program.

Just before executing this sample program.you have to install jdk.15 or jdk1.6
software in your system.

you have to set the Path and class path also.
Path to recognize the java compiler by your system
class path : to recognize the java virtual machine by your system

Java language have a java compiler.The compiler which converts your java code to
machine understandable format.(byte code) in java it creates .class file.

Java virtual machine which going to read the .class file and executes.

Steps to Set PATH and CLASSPATH


1. RightClick on MyComputer-->Properties-->select Advanced Tab.-->

there are 2 boxes click on new button from 2nd box.

2. give system varibale name as path and value C:\Program Files\Java\jdk1.5.0_05\bin

(if you installed in C drive)

3. now open command prompt and type javac .It will recognize your javac command.

4. now again click on new --> give variable name as JAVA_HOME

value as C:\Program Files\Java\jdk1.5.0_05

Some versions need classpath also

5. so give classpath as variable and value as

C:\Program Files\Java\jdk1.5.0_05\jre\lib\rt.jar;

now open command prompt and type java then you system will recognize.


Now start writing programs....



class Sample
{
public static void main(String[] args)
{

System.out.println("Hello World!");

}
}




Sample.java is your file name. You have to save this file with Sample.java.

Compile this file with the command java Sample.java

If it Compiles without any errors then it will generate a class file.(Sample.java)

Example: you saved you java file in c drive some Test folder

then open your command prompt

c:> cd Test

c:> javac Sample.java

c:>java Sample

Hello World!

--- This is the Output-----

- by Chaitu

Comments