Java Environment and Features
Java Environment and Features
Overview of Java
History of Java
Java Standards
Editions of Java
JDK and IDE
Characteristics of Java
Sample Java Program
Creating, Compiling and Executing Java Program
Java Runtime Environment (JRE) and Java Virtual Machine
(JVM)
Overview of Java
• Developed by a team led by James Gosling at Sun Microsystems in 1991 for use in
embedded chips .
• The primary motivation was the need for a platform-independent (that is,
architecture-neutral) language that could be used to create software to be embedded
in various consumer electronic devices, such as microwave ovens and remote
controls.
Computer languages have strict rules of usage. Java standards are defined
by
• Borland Jbuilder
• Microsoft Visual J++
• Net Beans
• Eclipse
• BlueJ
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Secure
• Java Is Robust
• Java Is Interpreted
• Java Is Distributed
• Java Is Architecture-Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
Characteristics of Java
Java Is Simple
Java is very easy to learn, and its syntax is simple, clean and easy to understand. According to
Sun, Java language is a simple programming language because:
Java syntax is based on C++ (so easier for programmers to learn it after C++).
Java has removed many complicated and rarely-used features, for example, explicit pointers,
operator overloading, etc.
Java Is Object-Oriented
Java is inherently object-oriented. Object-oriented programming provides great flexibility,
modularity, clarity, and reusability through encapsulation, inheritance, and polymorphism
Java Is Secure
Java is best known for its security. With Java, we can develop virus-free systems. Java is secured
because:
No explicit pointer
Java Programs run inside a virtual machine sandbox
Characteristics of Java
Java Is Robust
•Robust simply means strong. Java is robust because:
•It uses strong memory management.
•There is a lack of pointers that avoids security problems.
•There is automatic garbage collection in java which runs on the Java Virtual Machine to get rid of
objects which are not being used by a Java application anymore.
•There are exception handling and the type checking mechanism in Java. All these points make Java
robust.
Java Is Distributed
Java is distributed because it facilitates users to create distributed applications in Java. RMI’s are
used for creating distributed applications. This feature of Java makes us able to access files by
calling the methods from any machine on the internet.
Characteristics of Java
Java Is Architecture-Neutral
Write once, run anywhere. With a Java Virtual Machine (JVM), you can write one program that
will run on any platform.
Java is architecture neutral because there are no implementation dependent features, for
example, the size of primitive types is fixed.
•In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and 4
bytes of memory for 64-bit architecture. However, it occupies 4 bytes of memory for both 32
and 64-bit architectures in Java.
Java Is Portable
Java is portable because it facilitates you to carry the Java bytecode to any platform. It doesn't
require any implementation
Characteristics of Java
Java’s Performance
Java is faster than other traditional interpreted programming languages because Java
bytecode is "close" to native code.
• JRE – Java Runtime Environment (to say JRE) is an installation package which provides
environment to only run(not develop) the java program(or application)onto your machine. JRE is
only used by them who only wants to run the Java Programs i.e. end users of your system.
• JVM – Java Virtual machine(JVM) is a very important part of both JDK and JRE because it is
contained or inbuilt in both. Whatever Java program you run using JRE or JDK goes into JVM and
JVM is responsible for executing the java program line by line hence it is also known as
interpreter.
Understanding JDK, JRE and JVM
Various components of JDK & JRE
JDK
JDK is an acronym for Java Development Kit.
It physically exists. It contains JRE and development tools.
The Java Development Kit (JDK) is a software development environment used for developing Java
applications and applets.
It includes the Java Runtime Environment (JRE), an interpreter/loader (Java), a compiler (javac), an
archiver (jar), a documentation generator (Javadoc) and other tools needed in Java development.
JRE
JRE is an acronym for Java Runtime Environment.
It is the implementation of JVM and used to provide runtime environment.
It contains set of libraries and other files that JVM uses at runtime.
Understanding JVM
JVM (Java Virtual Machine) is an abstract machine.
It is a specification that provides runtime environment in which java byte code can be
executed.
JVMs are available for many hardware and software platforms.
The source code (program) written in java is saved as a file with .java
extension.
The java compiler “javac” compiles the source code and produces the platform
independent intermediate code called BYTE CODE. It is a highly optimized set
of instructions designed to be executed by the JVM.
How Java is Platform-independent?
The byte code is not native to any platform because java compiler doesn’t
interact with the local platform while generating byte code.
It means that the Byte code generated on Windows is same as the byte code
generated on Linux for the same java code.
The Byte code generated by the compiler would be saved as a file with .class
extension. As it is not generated for any platform, can’t be directly executed on
any CPU.
Q1
Which of the following component generates the byte code?
A.javac
B.java
C.javadoc
D.jar
Q2
Java is
A.Compiled
B.Interpreted
C.Compiled as well as Interpreted
D.None of these
Q3
JVM is to generate
A.Bytecode
B.Native code
C.Source code
D.Machine independent code
Q4
What is the extension of bytecode file?
A..exe
B..java
C..class
D..obj
Java Libraries, Middle-ware, and Database options
java.lang
java.util
java.sql
java.io
java.nio
java.awt
javax.swing
Sample Java Program