Ajava Unit V
Ajava Unit V
A JAR (Java Archive) is a package file format typically used to aggregate many
Java class files and associated metadata and resources (text, images, etc.) into
one file to distribute application software or libraries on the Java platform.
The basic format of the command for creating a JAR file is:
The c and f options can appear in either order, but there must not be any space
between them.
This command will generate a compressed JAR file and place it in the current
directory. The command will also generate a default manifest file for the JAR
archive.
You can add any of these additional options to the cf options of the basic
command:
to create a .jar file and related commands which help us to work with .jar files
1.1 Create a JAR file
In order to create a .jar file, we can use jar cf command in the following ways as
discussed below:
Syntax:
0 seconds of 16 secondsVolume 0%
INTERNATIONALIZATION
Before starting the internationalization, Let's first understand what are the
informations that differ from one region to another. There is the list of culturally
dependent data:
o Messages
o Dates
o Times
o Numbers
o Currencies
o Measurements
o Phone Numbers
o Postal Addresses
o Labels on GUI components etc.
Importance of Locale class in Internationalization
1. Locale(String language)
2. Locale(String language, String country)
3. Locale(String language, String country, String variant)
Java Swing tutorial is a part of Java Foundation Classes (JFC) that is used to
create window-based applications. It is built on the top of AWT (Abstract
Windowing Toolkit) API and entirely written in java.
The javax.swing package provides classes for java swing API such as JButton,
JTextField, JTextArea, JRadioButton, JCheckbox, JMenu, JColorChooser etc.
There are many differences between java awt and swing that are given below.
The Java Foundation Classes (JFC) are a set of GUI components which simplify the
development of desktop applications.
Do You Know
The methods of Component class are widely used in java swing that are given
below.
Method Description
We can write the code of swing inside the main(), constructor or any other method.
Let's see a simple swing example where we are creating one button and adding it on
the JFrame object inside the main() method.
File: FirstSwingExample.java
1. import javax.swing.*;
2. public class FirstSwingExample {
3. public static void main(String[] args) {
4. JFrame f=new JFrame();//creating instance of JFrame
5.
6. JButton b=new JButton("click");//creating instance of JButton
7. b.setBounds(130,100,100, 40);//x axis, y axis, width, height
8.
9. f.add(b);//adding button in JFrame
10.
11.f.setSize(400,500);//400 width and 500 height
12.f.setLayout(null);//using no layout managers
13.f.setVisible(true);//making the frame visible
14.}
15.}
ADVANCED JAVA TECHNIQUES
Advanced Java is everything that goes beyond Core Java – most importantly the
APIs defined in Java Enterprise Edition, includes Servlet programming, Web
Services, the Persistence API, etc. It is a Web & Enterprise application development
platform which basically follows client & server architecture.
1. Advance Java i.e. JEE (Java Enterprise Edition) gives you the library to
understand the Client-Server architecture for Web Application
Development which Core Java doesn’t support.
2. J2EE is platform Independent, Java Centric environment for developing,
building & deploying Web-based applications online. It also consists of a set
of services, APIs, and protocols, which provides the functionality that is
necessary for developing multi-tiered, web-based applications.
3. You will be able to work with Web and Application Servers like Apache
Tomcat, Glassfish etc and understand the communication over HTTP
protocol. But, in Core Java, it is not possible.
4. There are a lot of Advance Java frameworks like Spring, JSF,
Struts etc. which enable you to develop a secure transaction based web
apps for the domains like E-Commerce, Banking, Legal, Financial,
Healthcare, Inventory etc.
5. To work and understand the hot technologies like Hadoop and Cloud
services, you should be prepared with core and advanced Java concepts.
2. Concurrency
Concurrency having the ability in Advanced Java to execute multiple tasks
simultaneously, that runs independently and concurrently by allowing different
programs. Concurrency plays an important role as it maximises the performance,
enhances responsiveness, in simpler terms concurrency implements multiple
tasks at once, it has the synchronisation that prevents the data corruption and
race conditions, and deadlocks. Concurrency is vital in modern software
development where Java provides thread-safe collections like ConcurrentMap and
ConcurrentQueue that are accessed by multiple threads concurrently.
3. Multithreading
Multithreading is the process of having several tasks running together parallelly
within the same program, it improves the responsiveness to keep users interface
responsive by saving the time while performing time-consuming tasks in the
background simultaneously that divides a large task into smaller parts, that
could run concurrently. Multithreading has Java API features that creates and
manages thread easily. In Advanced Java by using multithreading in applications
developers can create more fast, secure, responsive, and capable, so that could
handle complex tasks efficiently.
4. JDBC
JDBC stands for “Java Database Connectivity” which is a very essential
component in Advanced Java for interacting with databases. JDBC connects with
various relational databases that executes the queries, and manipulates the data
with the help of Java APIs (Application Programming Interfaces). JDBC allows the
Java program to interact with the databases to retrieve information, store the
data, and update the data. In order to overcome the problems by using JDBC
directly,Spring framework has provided one abstraction layer on top of existing
JDBC technology, we used to call this layer as Spring-JDBC. Following are the
step-by-step connection of JDBC (Java Database Connectivity):
6. Spring Framework
1. IT is a popular non-standard open-source framework developed by Interface21
INC.
2. Aims to overcome the application problems by enabling the use of simple Java
Beans(POJO-Plain Old Java Objects) to implement the business logic.
3. Enables the developers to create and test the application very easily.
4. Aims to minimise the dependency of application code on its framework.
5. Enables the use of simplicity and ease of testability in standard application.
6. The Spring Framework has a layered architecture made up of several well
defined modules.
7. Hibernate
Hibernate is a Java Persistence Framework. Persistence is the availability of the
object/data even after the process that created it,is terminated.
There are 4 layers in the hibernate architecture:
1. Java application layer
2. Hibernate framework layer
3. Backend API layer
4. Database layer
9. Java Security
The term ‘Security’ means to ensure that your application is secured, and it
checks for valid users if they login, it may login successfully if the user is
authorised, but if the user is invalid then it is denied access to the application. So
basically, it works on two scenarios i.e. Authentication, and Authorization. It is a
good practice that is designed to enhance the security of Java applications and
the Java Runtime Environment (JRE).