0% found this document useful (0 votes)
3 views45 pages

Advanced Java1

The document is a lab report on Advanced Java Programming submitted for a Bachelor in Computer Application at Tribhuvan University. It includes various lab exercises that cover topics such as creating user interfaces, implementing design patterns, and interacting with databases using Java. The report is supervised by Mr. Binod Thapa and acknowledges contributions from various individuals.

Uploaded by

taccrs100x8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views45 pages

Advanced Java1

The document is a lab report on Advanced Java Programming submitted for a Bachelor in Computer Application at Tribhuvan University. It includes various lab exercises that cover topics such as creating user interfaces, implementing design patterns, and interacting with databases using Java. The report is supervised by Mr. Binod Thapa and acknowledges contributions from various individuals.

Uploaded by

taccrs100x8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 45

A

Lab Report on

Advanced Java Programming


(CACS-354)

FACULTY OF HUMANITIES AND SOCIAL SCIENCES

Tribhuvan University

Kirtipur, Nepal

Submitted By:

Submitted to:
CERTIFICATE FROM THE SUPERVISOR

This is to certify that the project Report entitled "Advanced Java Programming"
is an academic work done by "dghrh” submitted in the partial fulfillment of the
requirements for the degree of Bachelor in Computer Application at National
College under my guidance and supervision. To the best of my knowledge, the
work permed by him is his own creation.

----------------------------------------------

Signature of the supervisor


Name:Binod Thapa

Designation: Subject Teacher

Date:
VIVA-VOCE SHEET

We have conducted the viva-voce of the report presented by Mahan Gurung

Entitled: Advanced Java Programming

And found the report to be the original work of the student and written

according to the prescribed format. We recommend the report to be accepted as

partial fulfillment of the requirement for the degree of Bachelor in Computer

Application (BCA).

Viva-Voce Committee:

Member (Report Supervisor): __________________________

Member (External Expert): __________________________


DECLARATION

I hereby declare that the work reported in this report entitled "Advanced Java
Programming" submitted to office of the dean, Faculty of Humanities and social
Sciences, Tribhuvan University, is my original work done in the form of partial
fulfillment of the requirement of the degree of Bachelor in Computer
Application (BCA) under the supervision of our teacher Mr. Binod Thapa of
National College, T.U.

ACKNOWLEDGEMENT

.
I have taken efforts in this project. However, it would not have been possible
without the kind support and help of many individuals and organizations. I would like to
extend my sincere thanks to all of them. I am highly indebted to “Mr.Binod Thapa” for his
guidance and constant supervision as well as for providing necessary information
regarding the project and also for his support in completing the project.

I would like to express my gratitude towards Academic Director “Mr. Nava Raj
Heka” and my parent for their kind co-operation and encouragement which help me in
completion of this project. My thanks and appreciations also go to my friend in developing
the project and people who have willingly helped me out with their abilities.

Table of Content
La Title Date Signature
b
No.
1
Create Login user interface by Extending The JFrame
Class

2
Create Student register UI with first name and last name
by Instantiating The JFrame Class

3
Write a program to draw the pie chart in 2D

Write a program that creates a label displaying any text,


with the italics, font size and color with Layout manager

5 Write UI with one button when click on button its color


should changed using ActionLister

Write a program to implement MVC Design Pattern for


Employee object

7 .
Write a program to insert employee
information(name,email and address) into MYSQL
database

8.
Write a program to display emplyee information in table
from database

9 Write a program to create JAVA BEAN which connect


MYSQL database by passing email address and display
employee information by using implementing
setProperty and getProperty
10 Write a program to display student details using JSP.

11 Create Form in servlet with Username and password.


Read these values and display in the form.
12 Write a servlet program to store values in cookie and
display that value.

13 Write a servlet program to store username in session and


display tha value of session.

14 Write a simple client and server program using RMI.

Lab No.1

Title: To Create Login user interface by Extending The JFrame Class


Objective: To create a simple login user interface using Java Swing's JFrame class.

Theory:
Creating a login user interface is a common task in software development, especially for
applications that require user authentication. Extending the JFrame class in Java Swing
allows you to create graphical user interfaces (GUIs) with windows, buttons, text fields,
labels, and more.

Java Swing is a powerful graphical user interface (GUI) toolkit that allows developers to
create rich and interactive desktop applications in Java. It's a part of the Java Foundation
Classes (JFC) and provides a wide range of components and tools for building GUI-based
applications with cross-platform compatibility.

Swing was designed to address the limitations and shortcomings of the earlier Abstract
Window Toolkit (AWT), which had platform-dependent components and lacked some
advanced features. Swing provides a consistent look and feel across different operating
systems and offers greater flexibility in terms of customization and event handling.

Program:
Output:
Lab No.2
Title: To Create Student register UI with first name and last name by Instantiating The
JFrame Class

Objective: To create a simple student registration user interface using Java Swing's JFrame
class.

Theory:
Creating a student registration user interface is a common task in software development,
particularly for applications that require user input for data entry. Using Java Swing's JFrame
class allows you to design graphical user interfaces (GUIs) with various components like
labels, text fields, buttons, and more. In this case, the user interface will gather a student's
first name and last name for registration.

Program:
Output:
Lab No.3

Title:Write a program to draw the pie chart in 2D

Objective:To demonstrate how to create a simple 2D pie chart

Theory:
A pie chart is a circular statistical graphic that is used to represent data in a visually appealing
manner. Each "slice" of the pie represents a portion of the whole, and the size of each slice
corresponds to the proportion of the data it represents. Pie charts are commonly used to show
the distribution of a set of categories or to display data as parts of a whole.

Program:
Output:
Lab No.4

Title: Write a program that creates a label displaying any text, with the italics,
font size and color with Layout manager

Objective: To create a GUI application that showcases how to use the Swing framework to
create a label

Theory:
In GUI programming, a layout manager is a crucial component that helps arrange and
position GUI components within a container, such as a panel or a window. Layout managers
ensure that the components maintain a consistent appearance and alignment, regardless of the
screen size or the user's preferences. They play a vital role in creating flexible and responsive
graphical user interfaces.

Java provides a variety of layout managers as part of its GUI toolkit, including Swing and
JavaFX. These layout managers simplify the process of designing and structuring GUIs by
automatically handling the placement and resizing of components based on predefined rules.
Each layout manager has its own approach to managing the positioning and sizing of
components, allowing developers to choose the most suitable one for their specific design
requirements.

Common Layout Managers in Java Swing:

1.FlowLayout: This layout manager arranges components in a single row or column, with
options for alignment and spacing.

2.BorderLayout: Components are positioned in regions: north, south, east, west, and center.
It's useful for creating simple layouts with a header, footer, and central content area.

3.GridLayout: Components are arranged in a grid of rows and columns, ensuring all cells
have the same size.

4.GridBagLayout: A flexible and powerful layout manager that allows components to be


placed in a grid with varying sizes and spans.

5.BoxLayout: This layout manager arranges components in a single row or column, similar to
FlowLayout, but provides more control over alignment and spacing

6.CardLayout: Used to manage a set of components where only one component is visible at a
time, like a deck of cards.
Program:

Output:
Lab No.5

Title: Write UI with one button when click on button its color should changed
using ActionListener

Objective: To demonstrate how to create a basic UI with a button using the Swing
framework.

Theory:
User Interfaces (UIs) are an integral part of software applications, enabling users to interact
with the software's features and functionality. Java's Swing framework provides a rich set of
components and tools for building graphical user interfaces. In this example, we will create a
simple UI with a button, and when the button is clicked, its color will change. This
interaction will be achieved using the ActionListener interface.

Program:
Output:
Lab No.6

Title: Write a program to implement MVC Design Pattern for Employee object

Objective: To implement the MVC design pattern for managing Employee objects.

Theory:
The Model-View-Controller (MVC) design pattern is a widely used architectural pattern in
software development, especially for building user interfaces. It is an architectural pattern that
separates an application into three main logical components: the model, the view, and the
controller. Each of these components are built to handle specific development aspects of an
application. MVC is one of the most frequently used industry-standard web development
framework to create scalable and extensible projects.

MVC separates an application into three interconnected components: Model, View, and
Controller. This separation promotes code organization, maintainability, and flexibility in
designing complex applications.

Model: Represents the data and business logic of the application. It manages data and
responds to queries, modifications, and notifications from the View or Controller.

View: Represents the user interface elements and is responsible for displaying data from the
Model to the user. It should be passive and only display information.

Controller: Acts as an intermediary between the Model and View. It handles user input,
processes requests, updates the Model, and updates the View based on changes in the Model.

Program:
Output:
Lab No.7

Title: Write a program to insert employee information(name,email and address) into


MYSQL database

Objective: To show how to interact with a MySQL database to insert employee


information.

Theory:
Databases play a crucial role in storing and managing structured data for applications.
MySQL is a popular open-source relational database management system that is commonly
used in various software projects. This example program aims to demonstrate how to insert
employee information, including their name, email, and address, into a MySQL database
using Java. JDBC (Java Database Connectivity) will be used to establish a connection
between the Java application and the MySQL database.

Program:
Output:
Lab No.8
Title: Write a program to display employee information in table from database

Objective: To demonstrate how to fetch employee information from a database and present
it in a table format.

Theory:
Interacting with databases to retrieve and display data is a common task in software
development. Java provides various libraries and frameworks to facilitate this process. In this
example, we'll create a Java program that retrieves employee information from a database and
displays it in a table format using the JDBC (Java Database Connectivity) API.

JDBC (Java Database Connectivity) is a Java API that allows Java applications to interact
with databases. It provides a standardized way for Java applications to connect to relational
databases, execute SQL queries, and perform database operations. JDBC enables developers
to create database-driven applications by providing a consistent interface to various database
systems.

JDBC is a fundamental technology for database connectivity in Java applications. It allows


developers to build applications that interact with databases, perform CRUD (Create, Read,
Update, Delete) operations, and retrieve and manipulate data in a structured and efficient
manner.

MySQL is a relational database management system based on the Structured Query


Language, which is the popular language for accessing and managing the records in the
database. MySQL is open-source and free software under the GNU license. It is supported by
Oracle Company.

Program:
Output:

Lab No.9
Title: Write a program to create JAVA BEAN which connect MYSQL database by passing
email address and display employee information by using implementing setProperty and
getProperty

Objective: To demonstrate the creation and usage of a JavaBean to connect to a MySQL


database and retrieve employee information based on an email address.

Theory:
JavaBeans are reusable software components that follow a specific naming convention and
design pattern. They encapsulate data and provide getter and setter methods to access and
modify that data. In this example, we will create a JavaBean that connects to a MySQL
database, retrieves employee information based on an email address, and uses the setProperty
and getProperty methods to interact with the data.

Program:
Output:
Lab No.10

Title: Write a program to display student details using JSP

Objective: To demonstrate how to use JSP to display student details on a web page.

Theory:
JavaServer Pages (JSP) is a technology that allows developers to create dynamic web content
using Java and HTML. JSP pages are typically used to generate dynamic HTML content that
can be rendered in a web browser. In this example, we will create a simple JSP program to
display student details on a web page.

Program:
i. Index.jsp
ii. welcome.jsp
iii. StudentServlet.java
Output:
Lab No.11

Title: Create Form in servlet with Username and password. Read these values and display
in the form.

Objective: To demonstrate how to create a servlet that generates an HTML form for
entering a username and password.

Theory:
Servlets are Java-based components used to build dynamic web applications. They handle
requests and responses, allowing developers to create interactive and data-driven web pages.
In this example, we will create a simple servlet that creates an HTML form for entering a
username and password. The servlet will read the values submitted through the form and
display them back on the form.

Program:
i.index.html

ii.LoginServlet.java
Output:
Lab No.12

Title: Write a servlet program to store values in cookie and display that value.

Objective: To show how to use cookies in a servlet to store and retrieve data.

Theory:
Servlets are Java-based components that handle requests and responses in web applications.
Cookies are small pieces of data that can be stored on the client's browser and sent back to the
server with subsequent requests. In this example, we will create a servlet program that stores
a value in a cookie and then displays that value when requested.

Program:
i.CookieServlet.java
ii.index.html

Output:
Lab No.13

Title: Write a servlet program to store username in session and display tha value of session.

Objective: To show how to use sessions in a servlet to store and retrieve user-specific data.

Theory:
In Java web applications, a session is a way to maintain stateful information across multiple
requests and responses between a client and a server. Each user is assigned a unique session
object that can be used to store and retrieve user-specific data.

Program:
i.SessionServlet
ii.index.html

Output:
Lab No.14

Title: Write a simple client and server program using RMI.

Objective: To demonstrate a basic client-server interaction using RMI.

Theory:
RMI (Remote Method Invocation) is a Java technology that allows methods of remote objects
to be invoked as if they were local methods. RMI enables communication between Java
applications running on different machines, providing a way to create distributed applications
in which objects can interact across a network. In this example, we'll create a simple client-
server program using RMI to demonstrate how remote method invocation works.

Program:
i.Server.java

ii.Client.java
iii.Adder.java

iv.RemoteAdder.java

Output:

You might also like