FRST JAVA PROGRAM

Download Report

Transcript FRST JAVA PROGRAM

FRST JAVA PROGRAM
Getting Started with Java
Programming
• A Simple Java Application
• Compiling Programs
• Executing Applications
Java Applcation
//This application program prints
Welcome to java!
import java.lang.*;
public class Welcome
{
public static void main(String[]args)
{
System.out.println("Welcome to
Java!");
}
}
RUN JAVA PROGRAM
• Create hello.java
file
• To compile:
– javac hello.java
• To run:
– java hello
Create/Modify Source
Code
Source Code
Compile Source Code
i.e. javac Welcome.java
If compilation errors
Bytecode
Run Byteode
i.e. java Welcome
Result
If runtime errors or incorrect result
Bytecode (.class file)
Bytecode
• The Java compiler creates a bytecode. This is the
machine independent code so; it can be executed
on any machine. That is if you have created this
bytecode on Windows operating system then it can
be executed on Linux operating system.
• In order to make the Java as machine independent
language, the bytecode is introduced. However, the
Java Development Kit installed on different machine
is different for all of them.
Java Virtual Machine(JVM)
All the programming language compilers translate the source code into
machine code. Java compiler also performs the same function.
However, the difference between Java and the other compilers is that
Java compiler produces the intermediate code known as bytecode for
the machine that does not exist. This machine is called as Java Virtual
Machine.
Java Virtual Machine(JVM)
MSBTE Question Bank:
Q1 . What is bytecode? (s-07,s-09,s-12)
Q2 . What is bytecode explain JVM.(w-11,w-13)
Q3 . What is JVM? What is bytecode?(s-13)