Saturday 13 May 2017

JP - Compile and execute ~ foundjava

Compile and Run Java Program

In the Java programming language, all source code is first written in plain text files and save with the .java extension. After compilation, .class files are generated by javac compiler. A .class file does not contain code that is native to your processor; it instead contains bytecodes (it is machine language of the Java Virtual Machine1 (JVM)).
Compile Java Code
The java launcher tool then runs your application with an instance of the Java Virtual Machine (JVM).

Run Java Program

Steps For compile Java Program

  • First Save Java program with same as class name with .java extension. 
    Example: Sum.java
  • Compile: javac Filename.java 
    Example, javac Sum.java
Note: Here javac is tools or application programs or exe files which is used for Compile the Java program.

Steps For Run Java Program

  • For run java program use java tool.
  • Run by: java Filename 
    Example: java sum
Note: Here java is tools or application programs or exe files which is used for run the Java program.

Steps For compiling and executing the java program

The following sequence of steps represented in the diagram use compiling the java program and executing the java programs.
Compile and run java
In the above diagram javac and java are called tools or application programs or exe files developed by sun micro system and supply as a part of jdk 1.5/1.6/1.7 in bin folder (starting directory of java is called java home directory).

No comments:

Post a Comment