What is Java?
Java is a programming language and a platform.
Java is a high level, robust, object-oriented and secure
programming language.
Java was developed by Sun Microsystems (which is
now the subsidiary of Oracle) in the year 1995. James
Gosling is known as the father of Java. Before Java, its
name was Oak. Since Oak was already a registered
company, so James Gosling and his team changed the
name from Oak to Java.
Java Example
class Demo1{
public static void main(String args[]){
System.out.println("Hello Java");
}
}
Application
According to Sun, 3 billion devices run Java. There are many
devices where Java is currently used. Some of them are as
follows:
1.Desktop Applications such as acrobat reader, media
player, antivirus, etc.
2.Web Applications such as irctc.co.in, javatpoint.com, etc.
3.Enterprise Applications such as banking applications.
4.Mobile
5.Embedded System
6.Smart Card
7.Robotics
8.Games, etc.
Types of Java Applications
1) Standalone Application
Standalone applications are also known as desktop
applications or window-based applications. These are
traditional software that we need to install on every
machine. Examples of standalone application are Media
player, antivirus, etc. AWT and Swing are used in Java for
creating standalone applications.
2) Web Application
An application that runs on the server side and creates a
dynamic page is called a web application. Currently, Servlet,
JSP, Struts, Spring, Hibernate, JSF, etc. technologies are used
for creating web applications in Java.
3) Enterprise Application
An application that is distributed in nature, such as banking
applications, etc. is called an enterprise application. It has
advantages like high-level security, load balancing, and
clustering. In Java, EJB is used for creating enterprise
applications.
4) Mobile Application
An application which is created for mobile devices is
called a mobile application. Currently, Android and
Java ME are used for creating mobile applications.
Java Platforms / Editions
1) Java SE (Java Standard Edition)
It is a Java programming platform. It includes Java
programming APIs such as java.lang, java.io, java.net,
java.util, java.sql, java.math etc. It includes core topics like
OOPs, String, Regex, Exception, Inner classes,
Multithreading, I/O Stream, Networking, AWT, Swing,
Reflection, Collection, etc.
2) Java EE (Java Enterprise Edition)
It is an enterprise platform that is mainly used to develop
web and enterprise applications. It is built on top of the Java
SE platform. It includes topics like Servlet, JSP, Web
Services, EJB, JPA, etc.
3) Java ME (Java Micro Edition)
It is a micro platform that is dedicated
to mobile applications.
4) JavaFX
It is used to develop rich internet
applications. It uses a lightweight user
interface API.
Difference between JDK, JRE, and JVM
1.A summary of JVM
2.Java Runtime Environment (JRE)
3.Java Development Kit (JDK)
JVM
JVM (Java Virtual Machine) is an abstract machine. It is
called a virtual machine because it doesn't physically exist.
It is a specification that provides a runtime environment in
which Java bytecode can be executed. It can also run those
programs which are written in other languages and
compiled to Java bytecode.
JVMs are available for many hardware and software
platforms. JVM, JRE, and JDK are platform dependent
because the configuration of each OS is different from each
other. However, Java is platform independent. There are
three notions of the JVM: specification, implementation,
and instance.
The JVM performs the following main tasks:
•Loads code
•Verifies code
•Executes code
•Provides runtime environment
JRE
JRE is an acronym for Java Runtime Environment. It is
also written as Java RTE. The Java Runtime Environment
is a set of software tools which are used for developing
Java applications. It is used to provide the runtime
environment. It is the implementation of JVM. It
physically exists. It contains a set of libraries + other
files that JVM uses at runtime.
The implementation of JVM is also actively released by
other companies besides Sun Micro Systems.
JDK
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 physically exists. It contains
JRE + development tools.
JDK is an implementation of any one of the below given Java
Platforms released by Oracle Corporation:
•Standard Edition Java Platform
•Enterprise Edition Java Platform
•Micro Edition Java Platform
The JDK contains a private Java Virtual Machine (JVM) and a few other
resources such as an interpreter/loader (java), a compiler (javac), an
archiver (jar), a documentation generator (Javadoc), etc. to complete
the development of a Java Application.
Features of Java
The primary objective of Java programming
language creation was to make it portable, simple
and secure programming language. Apart from
this, there are also some excellent features which
play an important role in the popularity of this
language. The features of Java are also known as
Java buzzwords.
A list of the most important features of the Java language is given below.
1.Simple
2.Object-Oriented
3.Portable
4.Platform independent
5.Secured
6.Robust
7.Architecture neutral
8.Interpreted
9.High Performance
10.Multithreaded
11.Distributed
12.Dynamic
First Java Program | Hello World Example
In this section, we will learn how to write the
simple program of Java. We can write a simple
hello Java program easily after installing the JDK.
To create a simple Java program, you need to
create a class that contains the main method. Let's
understand the requirement first
The requirement for Java Hello World
Example
For executing any Java program, the following software or
application must be properly installed.
•Install the JDK if you don't have installed it,
download the JDK and install it.
•Set path of the jdk/bin directory.
http://www.javatpoint.com/how-to-set-path-in-java
•Create the Java program
•Compile and run the Java program
Creating Hello World Example
1.class Simple{
2. public static void main(String args[])
{
3. System.out.println("Hello Java");
4. }
5.}
Compilation Flow:
When we compile Java program using javac tool, the Java compiler
converts the source code into byte code.
Hello Java
Parameters used in First Java Program
Let's see what is the meaning of class, public, static, void, main, String[],
System.out.println().
•class keyword is used to declare a class in Java.
•public keyword is an access modifier that represents visibility. It means it is visible to
all.
•static is a keyword. If we declare any method as static, it is known as the static
method. The core advantage of the static method is that there is no need to create an
object to invoke the static method. The main() method is executed by the JVM, so it
doesn't require creating an object to invoke the main() method. So, it saves memory.
•void is the return type of the method. It means it doesn't return any value.
•main represents the starting point of the program.
•String[] args or String args[] is used for command line argument. We will discuss it
in coming section.
•System.out.println() is used to print statement. Here, System is a class, out is an
object of the PrintStream class, println() is a method of the PrintStream class. We will
discuss the internal working of System.out.println() statement in the coming section.
To write the simple program, you need to open notepad by start menu -> All Programs ->
Accessories -> Notepad and write a simple program as we have shownbelow:
As displayed in the above diagram, write the simple program of Java in notepad and saved it as
Simple.java. In order to compile and run the above program, you need to open the command prompt
by start menu -> All Programs -> Accessories -> command prompt. When we have done with
all the steps properly, it shows the following output: