Jul 9, 2007

How To Compile and Run a JAVA Program :

Step 1: Type your JAVA Program into any text editor like notepad or Edit (Dos Based Editor).

Step 2: Save your program (filename.java). You should use four characters extension .java just for example

hello.java.

Step 3: Compile your program with the follwing command at dos prompt
where your java compiler exist. in my case c:\jdk folder.

So first of all you have to change the directory

c:\> cd jdk
c:\jdk> cd bin

c:\jdk\bin> JAVAC hello.java

Javac is a java compiler.
if compilation is successfully done, it will create a hello.class file.

If your program contains 3 classes then it automatically creates 3 .class file, each file for each classes.
It is the file which contains byte code.

To run a java program

c:\jdk\bin>java hello

where java is a interpreter and hello is a .class file. And you are done. you have sucessfully compiled and run

your java program.

No comments:

Post a Comment