Introduction To Java
Introduction To Java
Java
Introduced in 1995.
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.
Types of Java Applications
3) Enterprise Application
An application that is distributed in nature, such as banking
applications, etc. is called enterprise application. It has
advantages of the 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.
Embedded System
Smart Card
Robotics
Games, etc.
Java Platform 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.
4) JavaFX
It is used to develop rich internet applications. It uses a light-weight
user interface API.
Features of Java Programming
1. Simple
While Java is verbose, its syntax is similar to C++. This makes it easier
to transition from C++ to Java. It has removed rarely-used features like
operator overloading and explicit pointers. There is no need to remove
unreferenced objects because there is an Automatic Garbage Collection in
Java.
2. Object-oriented
Java mainly focuses on objects rather than processes. Java follows the
principles of Object-Oriented Programming (OOP):
• Objects
• Classes
• Inheritance
• Encapsulation / Data hiding
• Abstraction
• Polymorphism
Note- Java isn’t a purely object-oriented language as it allows primitive data
types
3. Platform-independent
Platform independent means that the java source code can run on
multiple operating systems. Java code should run on any machine that
doesn’t need any special software to be installed, yet the JVM needs
to be present in the machine. Java code is compiled into bytecode,
which is platform-independent. You can run it on Windows, Linux, Mac
OS, etc.
platform = processor + Operating System
4. Portable
Java is portable because Java code can be executed on all the
major platforms. Once you’ve compiled your Java source code to
bytecode, those files can be used on any Java-supported platform
without modification, unlike other languages, which requires
compiling the machine code for each platform, for example, a separate
.exe for 32-bit vs 64-bit environments. Java is portable because you
can carry bytecode over to any other platform it runs on.
5. Robust
The following features make Java strong and powerful:
There is no use of explicit pointers
Strong memory management
Automatic garbage collection is done so you don’t need to
delete the unreferenced objects manually.
Exception handling and type-checking mechanisms
6. Secure
No explicit pointer
Java Programs run inside a virtual machine sandbox
Bytecode Verifier: It checks the code fragments for illegal
code that can violate access right to objects.
Security Manager: It determines what resources a class can
access such as reading and writing to the local disk.
The Security Manager decides what resources to allot to a
class. Such access can include reading and writing files.
Java can help you develop virus-free systems.
7. Distributed
Java is distributed because it facilitates users to create distributed applications in Java. RMI
and EJB 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.
8. Multi-threaded
A thread is like a separate program, executing concurrently. We can write Java programs that deal
with many tasks at once by defining multiple threads. The main advantage of multi-threading is that
it doesn't occupy memory for each thread. It shares a common memory area. Threads are important for
multi-media, Web applications, etc.
9. Architecture-neutral
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 Architecture – The Java Environment
1. JDK (Java Development Kit)
JDK is Kit which provides the environment to develop and
execute the Java program. It includes Development Tools to provide
an environment to develop your Java programs and JRE to execute
your java code. Along with the JRE, JDK contains other resources
like the interpreter/loader (java), the compiler (javac), an
archiver (jar), and a documentation generator (Javadoc). Together
these components help you to build Java programs.
2. Class Area – This stores class structures like the runtime constant
pool, and the field and method data.