Unit 1: Introduction To Java
❑ Java Virtual Machine (JVM)
❑ Java Runtime Environment (JRE)
❑ Java Development Kit (JDK)
JDK
Compiler Java Packages
(javac.exe) (math, util, awt
Java Application etc…)
Launcher JVM
(java.exe),
AppletViewer, etc.. Runtime
Libraries
Development tools
JRE
❑ JDK is an acronym for Java Development Kit.
❑ The Java Development Kit (JDK) is a software
development environment which is used to develop
Java applications and applets.
❑ It contains JRE + development tools.
⚫ The JRE is required to run java applications.
⚫ It combines the Java Virtual Machine (JVM), platform core classes
and supporting libraries.
⚫ JRE is part of the Java Development Kit (JDK), but can be
downloaded separately.
❑ JVM is a virtual machine that enables a computer to run Java
programs as well as programs written in other languages and
compiled to Java Bytecode.
❑ Byte code is intermediate representation of java source code.
❑ Java compiler provides byte code by compiling Java Source Code.
❑ Extension for java class file or byte code is ‘.class’, which is platform
independent.
❑ JVM interprets the byte code into the machine code.
❑ JVM itself is platform dependent, but Java is Not.
Source code
(Program) .java file
Compiler
Bytecode .class file
JVM JVM JVM
(Windows) (Linux) (Mac)
Machine Code Machine Code Machine Code
File must be saved as
HelloWorld.java
public class HelloWorld
Main method from where
{ execution will start
public static void main(String[] args)
{ String must start with
System.out.println("Hello World"); capital letter
}
System must start
} with capital letter
⚫ We have to save this in HelloWorld.java file as it has public class
named HelloWorld.
⚫ String and System are inbuilt Java Classes.
⚫ Classes in java are always written in Camel case.
❑ Save the program with the same name as the public class with .java
extension.
❑ Open command prompt (cmd) / terminal & navigate to desired
directory / folder.
❑ Compile the “.java” file with javac command.
Javac HelloWorld.java
❑ Execute the “.class” file with java command without extension.
Java HelloWorld
• The Java compiler breaks the line of code into text (words) is
called Java tokens.
• These are the smallest element of the java program
• Tokens can be classified as follows:
• Keywords
• Identifiers
• Constants
• Special Symbols
• Operators