Session-01
Objective
In this session you will learn :
The Java Technology Phenomenon
What is Java?
What is Programming Language?
What about Java Platform ?
What is File extension of Java?
What about java Compiler?
What Can Java Technology Do?
Overview of Java
History of Java & Java Version History
JDK, JRE & JVM
Main() Method & Command line arguments
The Java Technology Phenomenon
Talk about Java technology seems to be everywhere, but what exactly is it?
Java
Java is a programming language and a platform.
Programming LanguagePlatform
What is Programming Language?
Programming Language
A programming language is a formal constructed language designed to communicate
instructions to a machine, particularly a computer.
Programming languages can be used to create programs to control the behaviour of
a machine or to express algorithms.
Say Hello
Error
Continue...
Say
Hello10101
10101Hello
Compiler
Interpreter
Programming Languages
Platform
A platform is an underlying computer system on which application programs can run.
What about Java Platform ?
A platform is the hardware or software environment in which a program runs.
We've already mentioned some of the most popular platforms like Microsoft
Windows, Linux, Solaris OS, and Mac OS. Most platforms can be described as a
combination of the operating system and underlying hardware.
The Java platform differs from most other platforms in that it's a software-only
platform that runs on top of other hardware-based platforms.
Continue...
Java is cross platform in the sense that a compiled Java program runs on all
platforms for which there exists a JVM.
(This holds for all major operating systems, including Windows, Mac OS and Linux.)
.jar file can be distributed and executed on Windows systems, Mac systems, etc.
Java byte code won't need to be recompiled when you switch platforms.
C and C++ will require that the developer recompile the application before distributing
it to the target system,
But once that's done clients will be able to run without an issue.
How to create cross platform application?
Write your application in Java (In .java files)
Compile your application using Eclipse or javac (into .class files)
(Optionally) Bundle your .class files in an executable (.jar file)
What is File extension of Java?
.java is for the source code.
when source code gets compiled then generate .class file.
Language Extension
C .c
C++ .CPP
ASP .asp
C# .cs
PHP .php
Java .java
What about java Compiler?
Each language has own Compiler.
In Java, programs are not compiled into executable files like c , c++ etc...
They are compiled into Bytecode , which the JVM then executes at runtime.
Java source code is compiled into bytecode when we use the javac compiler.
The bytecode gets saved on the disk with the file extension .class.
When the program is to be run, the bytecode is converted, using the Just-In-Time
(JIT) compiler.
The result is machine code which is then fed to the memory and is executed.
So Java has two step compilation:
To create byte-code
To create machine level code
Continue...
Java compilers
Note: The GNU General Public License (GNU GPL or GPL) is the most widely used free software license, which guarantees end users (individuals, organizations, companies) the freedoms to use, study, share (copy), and modify the software.
Example
What Can Java Technology Do?
According to Sun, 3 billion devices run java. There are many devices where java is
currently used.
Some of them are as follows:
How Will Java Technology Change My Life?
Get started quickly
Write less code
Write better code
Develop programs more quickly
Avoid platform dependencies
Write once, run anywhere
Distribute software more easily
Types of Java Applications
Standalone Application
Web Application
Enterprise Application
Mobile Application
Overview of Java
Java divided into three categories, they are
J2SE
J2EE
J2ME
Evolution of Programming Languages
History of Java
James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language
project in June 1991. The small team of sun engineers called Green Team.
Originally designed for small, embedded systems in electronic appliances like set-top
boxes.
Firstly, it was called "Greentalk" by James Gosling and file extension was .gt.
After that, it was called Oak and was developed as a part of the Green project.
Why Oak? Oak is a symbol of strength and choosen as a national tree of many
countries like U.S.A., France, Germany, Romania etc.
In 1995, Oak was renamed as "Java" because it was already a trademark by Oak
Technologies.
Why they choosed java name for java language?
The team gathered to choose a new name. The suggested words were "dynamic",
"revolutionary", "Silk", "jolt", "DNA" etc. They wanted something that reflected the
essence of the technology: revolutionary, dynamic, lively, cool, unique, and easy to
spell and fun to say.
According to James Gosling "Java was one of the top choices along with Silk". Since
java was so unique, most of the team members preferred java.
Java is an island of Indonesia where first coffee was produced (called java coffee).
Notice that Java is just a name not an acronym.
Originally developed by James Gosling at Sun Microsystems (which is now a
subsidiary of Oracle Corporation) and released in 1995.
In 1995, Time magazine called Java one of the Ten Best Products of 1995.
JDK 1.0 released in(January 23, 1996).
Java Version History
Java Platform Standard Edition 7
JDK
JDK is an acronym for Java Development Kit. It physically exists. It contains JRE +
development tools.
lib BINJRE
JDK
JRE
JRE is an acronym for Java Runtime Environment. It is used to provide runtime
environment. It is the implementation of JVM.
It physically exists. It contains set of libraries + other files that JVM uses at runtime.
libBIN
JVM
JRE
Other Files
JVM
JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides
runtime environment in which java bytecode can be executed.
JVMs are available for many hardware and software platforms.
JVM, JRE and JDK are platform dependent because configuration of each OS
differs.
But, Java is platform independent.
The JVM performs following main tasks:
1. Loads code
2. Verifies code
3. Executes code
4. Provides runtime environment
Basic Structure-1
Basic Structure-2
JVM provides definitions for the:
Memory area
Class file format
Register set
Garbage-collected heap
Fatal error reporting etc.
Internal Architecture -1
Internal Architecture -2
For Java, JVM also contains heap and stack in runtime data area.
Objects and arrays are created on heap, method frames are pushed to stack.
One heap is shared by all threads, while each thread has its own stack.
Internal Architecture -3
runtime physical memory of a process.
mostly threads just map to OS threads, at which point they get their own stack, same
as any thread on the OS.
Example-1
Main() Method
main() method is starting execution block of a java program or any java program
start their execution from main method.
If any class contain main() method known as main class.
Understanding first java program
System.out.println() is used print statement. We will learn about the
internal working of System.out.println statement later.
How many ways can we write Main Method
To write the simple program in Notepad
Open Command Prompt
In Command Prompt
To compile: javac Simple.java
To execute: java Simple
Command line arguments
If any input value is passed through command prompt at the time of running of
program is known as command line argument
by default every command line argument will be treated as string value and those
are stored in string array of main() method.
Example of command-line argument in java
Summary!!