Lecture I (Introduction to Java Programming)
Lecture I (Introduction to Java Programming)
Programming
• Because of its rich set of API's, and its platform independence, Java can also be
thought of as a platform in itself.
• Much of the syntax of Java is the same as C and C++. One major difference is that Java
does not have pointers.
• However, the biggest difference is that you must write object oriented code in Java.
History of Java
• Java was started as a project called "Oak" by James Gosling in June 1991.
• First major JDK (Java Development Kit) 1.0 was released on January 21, 1996.
• The latest java version is Java™ SE Development Kit 21 (JDK 21) released on 19
September 2023.
Editions of Java
• One can easily install more than one version of JDK on the same computer.
• The Java developers can make use of it on macOS, Windows and Linux.
• It is a type of software package that provides class libraries of Java, JVM, and various
other components for running the applications written in Java programming.
• All the versions of JDK come bundled up with the JRE (Java Runtime Environment).
What is JVM?
• Java Virtual Machine(JVM) provides a runtime environment for driving Java applications
or code.
• JVM is an abstract machine that converts the Java bytecode into a machine language.
Difference Between JDK, JRE, JVM
JVM= Only
the runtime
JRE = Libraries for running
environment
the application + JVM (Java
that helps in
Virtual Machine)
executing the
Java
bytecode
Java File
Class File
Java Installation
1. Install Java for Windows(e.g. Download and Install jdk-16.0.2_windows-
x64_bin.exe )
2. Set up Environmental Variable for Java on Windows 10
• Right-click on This PC icon
• Choose Advanced System Settings
• Click the Advanced tab
• Click Environment Variables button
• double click on Path in System Variables session
• Add your JDK path (e.g. C:\Program Files\Java\jdk-16.0.2\bin) to Path
System.out.println("Hello World");
}
}
2. Compile the program
javac HelloWorld.java
• static: It says this method belongs to the entire class and NOT a part of any objects
of class. The main must always be declared static since the interpreter uses this
before any objects are created.
• void: The type modifier that states that main does not return any value.
• A program must include a method called main where the program starts. The
argument to main must always be a string array (containing any command line
arguments).
Faculty of Computer Science, University of Computer 18
Studies, Yangon
System.out.println(“Hello World”);
• java.lang.*
• All classes/items in “lang” package of java package.
• System is really the java.lang.System class.
• System.out.println() invoke the println() method of the “out” field of
the java.lang.System class.
• Command line input arguments are passed in the String array args[]
e.g. java HelloWorld John Jane
args[0] – John args[1] – Jane