Java Compilation and Exectuion Process---simple java program compilation

In the Java programming language, all source code is first written in plain text files ending with the .java extension. Those source files are then compiled into .class files by the javac compiler. A .class file does not contain code that is native to your processor; it instead contains bytecodes — the machine language of the Java Virtual Machine1 (Java VM). The java launcher tool then runs your application with an instance of the Java Virtual Machine. 

Steps:-
1.write your code in ".java" File say  Demo.java. Use Notepad or Notepad++.Save it on your HDD.let us suppose it is saved on Desktop.
2.Open Command Prompt and first set Directory where You saved Your File(here we saved on desktop).
Use Command(windows)
cd desktop
Now,set the path upto the bin folder in JDK where all java tools are present.
use cmomand(for windows)
set path  C:\Program Files\Java\jdk1.7.0\bin;
3.Compile the .java file ---->javac FileName   javac Demo.java
4.this produces a .class file(native to JVM not to Processor) here it will be Demo.java
5.run the >class file using java tool----->java ClassName    
java Demo
in this way you can run your simple application
you can try the below given code
 
class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!"); // Display the string.
    }
}
Save it with  HelloWorldApp.java and do the above procedure

1 comments:

for ict 99 said...

great

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Lady Gaga, Salman Khan