Java Projects for Beginners | Java Open Source Projects | Java Certification Training | Edureka

Sharing buttons:


hey everyone this is Neha from add

Eureka I welcome you all to this session

on Java projects in this session we will

be discussing three useful projects

which are based on code and advanced

Java concepts the projects that I will

be discussing today are ATM machine

which is based on core java concepts

text editor that is based on swings and

applets and the signup form which will

make use of servlets and JSP concepts

without wasting any further time let's

get started first ATM machine all of you

know what is ATM and how it works but

implementing the same using course our

concepts as something interesting so

let's see how to do that here we will be

developing the code for user account

details bank account and then further we

will perform few operations like deposit

the amount withdraw check the balance

etcetera basically it's based on kochava

concepts and stef locked using eclipse

so all that you require is your Chava

install that is your JDK and JRE and you

just need to have Eclipse installed on

your machine let me tell you one

important thing

that as I have said the privileges for

account number and password that is you

can see on the screen that I have given

two account numbers and passwords while

running the code if you give the account

number and password as mentioned on the

screen only then you can do the further

operations else it will just display a

message saying wrong account number

orphan now let's see how it works and

how the code is being developed so

basically when you run the code this is

how your console appears and it asked me

to enter the account number that will be

the one which I mentioned on the screen

and password is going to be this thing

enter so when you enter this it will ask

you to select the account you want to

access status whether your checking

account your saving account etcetera so

first I will say type one that is

checking account so in the checking

account the operations that you can do

as you can waive the balance you can

withdraw funds you can deposit the funds

so let's see how much balance is there

in my account it's zero is it now I want

to deposit the funds and the checking

account so how will I do that again

checking account option 3 which is

deposit funds so it's asking me amount

you want to deposit from checking

account so I say I want to deposit some

ten thousand enter so you can see here

the new checking account balance is ten

thousand correct again I will choose

checking account and now I want to

withdraw the imam from the checking

account so I'll say option two I'll say

I want some five thousand from that

account so you can see here I've

withdrawn five thousand and the new

checking account balance will be five

thousand so this implies I haven't drawn

five thousand from the account again I

will choose option one

I will view the balance so it says five

thousand is remaining correct now we'll

go to savings account and again view the

balance and do the same operations

balance is zero again same thing I want

to withdraw some funds like say four

thousand it says four thousand and now I

want to be draw some funds say some five

thousand let's see what it says when the

amount that we want to withdraw is more

than the amount and the bank

account it says balance cannot be

negative correct so when you try to

access more amount and which is there in

the bank account like the savings

account it says balance cannot be

negative similarly you cannot just enter

the negative values into this now say I

want to just withdraw some two thousand

and it says the new saving account

balance will be two thousand so

basically this is how you can do

operations like same way you do it on

your ATM machines and now I want to just

say I want to exist

suppose if I enter invalid account

numbers say I'll enter something like

this and I'll give the pin something it

says wrong customer number or pin number

that as I have said the privileges only

for those two are confident shifts so

that I can access using only those two

numbers you can even include more

account numbers and pins I'll show you

how to do that

so basically this is all about the

working of ATM machine let's take a look

at the core now so here in a Eureka one

package I have created three Java files

one is for account one is ATM and one is


so now let's see why we have three files

for ATM and how it works

first we'll see option menu so you can

see here option menu extents account

class that does this Java class I'm just

reading a money format that will be in

decimal and then I'm creating a hash map

of integer and then I'm creating a

variable of type hash map and leaving a

reference for that so basically the

first thing that I want to do is I want

to validate the login information that

is customer number and the number as I

have already told you that I have said

the privileges for two numbers that does

these two account numbers and pins if

you want more you can just copy this

data output paste it or you can change

like whatever you want you can add more

number of privileges like this so the

first step when you execute it will just

say welcome to ATM project and enter

your customer number correct so first

what you will do you will enter either

of these customer numbers and then it

will ask for pin number I'm reading the

customer number and pin number using

menu input dot next int so in case if

you enter some characters it has to

catch an exception correct so what it

will do it will say invalid characters

and it will ask you to enter only

numbers because I have set the

privileges only phone numbers so in this

for loop I am trying to check whether

the entered customer number and pin

number is correct or not if it is not

correct it will print saying wrong

customer number or pin number that you

already saw on the output so after that

if the enter credentials are correct

then this method will execute that is

the get account type in this get account

type I have mentioned these choices that

the select the account you want to

access checking account saving account

choice etc and then using the switch

case I am using get checking get saving

methods if you press exit it will say

thank you for using the ATM bye and in


for choice if you press a choice that is

not correct it will say in ballad choice

so here is the gate checking and I have

defined the method over here that does

get checking so what all we had and the

gate checking method view balance

withdraw funds deposit funds I said

correct now I am reading everything that

is account balance using money format

withdraw input deposit input and

everything will be in get account type

method correct

and obviously case four will be your

exit so it will just print saying thank

you for using the ATM pipe now similarly

for savings account that is view balance

with draw funds deposit funds etc again

we are using switch case to print the

saving account balance saving withdraw

input saving deposit input everything so

this is all about your option menu class

now we will see what is there an account

class so here it is just required to set

the customer number and set the pin

number that is first set the customer

number and written customer number and

then you set the pin number and return

the pin number so basically account

class is to retrieve all the details

that has been set in option menu that is

your checking balance saving balance

your withdraw and put deposit funds

everything that has been mentioned and

option menu class so you can see here

that I have checking balance method and

I am returning the same and again I have

saving balance so here you can calculate

the checking account withdrawal that is

checking balance equals to checking

balance minus account and then it will

return the sim that as we saw that when

we want to withdraw 2000 from 4000 it

will say the new saving balance will be

2000 similarly the same thing will be

here that is saving by ones- amount like

that so similarly you can calculate the

account deposit the saving account

deposit that is the balance plus amount

that you enter suppose say the saving

balance is 0 and if you enter 2000 so it

will add and it will return the balance

similarly the same thing with this as

well that is account withdraw and put

pan customer saving account withdraw

input as well and then it will just

check the deposit amount same thing for

savings as well

and I have initialized all these

variables as private because I want them

to be local to the class so this is how

it works and now coming to the last file

that this ATM dot Java so here this

class extents option menu and option

menu extends occur so what ATM should do

it should obviously extend option menu

and I'm just creating an object of

option menu and just trying to get the

log in from option menu so when I

execute again

it works same it lasts same thing again

if I enter something it says your own

custom opinion account number as I have

told if I enter something else apart

from the numerix it says invalid

characters only numbers that is the

exception that I have thrown so this is

all about the ATM project I hope you

understood it now let's move further and

see the text editor so here I am making

use of Java swings that as I will be

using J text area menu bar J menu bar

etc and all the menu items will have

action listener to detect any action and

as I have told it makes use of Java

applet and spring concepts and similarly

all that you just need is a Java

installed on the Eclipse IDE we can say

like we can perform all the operations

like we perform in your WordPad or your

notepad and it's very efficient so now

let's see how it works

so first let's execute and see how it

works and then I will explain you the


so you got a text editor here you can

see you have file and it consists of all

the operations like new open safe exit

and you have edit option like cut copy

and paste

you have font like bold plain italic and

half size like up to 28 and you have

font I practice Roman Helvetica Arial

collier century etc and also you can set

the background and foreground color and

you can undo and redo the operations now

let's see each of them how it works so I

want to say like

welcome to ed Eureka YouTube channel and

enjoy learning now suppose I want to

change the font of this I'll capture

everything like controlling and then

I'll give font like bold so you can see

here it became bored say suppose I

wanted to be italic you can see even

that became italic as well I want to

increase the font size like 28 it got

done I want to change the font type to

century when that happened say I want

Helvetica I want Times Roman even that

happened say I want a color to give for

that like background color and something

like say I want red okay you can see the

background color is red so I want to

remove the background color now now I

will change the font color to be

so I want to enter some more text like I

did as Java projects and I want to undo

that I can just press ctrl-z it goes on

removing all that thing and ctrl v for

whatever I have deleted you can see it's

going on also you can create a new file

that I just read also if you want to

open something that was already present

you can open from the libraries also if

I want to save this I can save it like

however I want in the Downloads or in

desktop whatever you want you can save

the file by giving save it it will be


I can under something and again if I

want to save it it will be saved like

applet one similarly we can even check

that whether it is being saved or not

so in desktop you can see it as being

saved as Apple an applet one so

basically this is all about your text

editor as how it works like you can

perform all the operations like edit

form file color

undo redo everything etc sounds

interesting let's see what is the code

behind this now

so here you can see a undoable text area

that extends a text area an implement

state editable white implement state

editable is because we have defined the

editable class in which we can edit all

the options like I showed you on the

text editor so you can see here I have

given the key state as undoable text

area key and then I have declared the

current edit and undo manager and the

first undoable text area I have defined

it in various ways the first thing is

zero parameterised and then the next I

have defined some parameters like string

and I have given it in super as well and

then I have used rows and columns and

then I have used string along with rows

and columns and then string rows columns

and scroll bars as well so in various

ways I have declared this undoable text

area constructor so if in case something

happens you are stuck and you cannot

undo some operations that you have

performed then automatically the

exception will be catch here and next

same for redo as well if you cannot

perform any video operations then it

again catches an exception you might be

wondering why it need to catch an

exception correct it's just because to

maintain the normal flow of execution so

that your further operations will not be

interrupted and next we will store the

state and restore the state that I have

given I'm using the key Siddhas variable

and for the snapshot method I am giving

like condition if the text is being

changed then use undo and added it to

edit the current state and now I am

declaring the init undoable and giving

some new reference variables for undo

manager and current edit and I'm adding

the key listener for new adapter and

then I'm using the focus listener to

focus the even that was being captured

and similarly for text listener as well

if the value is changed it has to say

that the text is being changed and now

you can see there's a text editor class

which undoable text area has extended

and this I am declaring few parameters

like frame file dialogue font etc and

now here comes the text editor

parameters like say courier add style at

size everything and here I have used the


menu bar that this times Roman Helvetica

Arial century etc I have given one one

parameters for each of them and then

using the add method I'm adding all of

them like appending it to the menu and

we have to use the action listener to

detect any action that is being

performed so similarly for bold plain

italic menu that all we saw and again

using action listener we are calling

that even and then I'm declaring all the

sizes over here that you saw little 28

and appending it using the add method

and to detect them I am using add action

listener even for new open save exit

again using action listener for all them

and for cut copy paste edit options as

well for background and foreground color

and for color for undo redo for

everything it all remains the same and

then I'm implementing the action

listener class to invoke that method

correct like for undo and redo and

similarly for filename untitled for

select menu everything so whatever the

options we have seen here they all have

to implement the action listener class

so you can see I am detecting save else

what happens the action will not be

detected you can see again for exit as

well for read file everything and even

cut copy paste for everything we have to

use action listener classes even the

size class implements action listener

like for a size 10 size 12 for 14 16 18

similarly till 28 that's all and then

I'm extending an applet class and

implementing the action listener even

for this in bold I want courier font

everything and even in plain I wants the

same thing so as you can see if I type

anything here so it is by default color

correct so that's what is here that is

in get action command and bold plain and

italic whatever it is the first singers

career correct and then comes the type

that the Stynes Roman Helvetica quarry

or Arial black century everything and

then again I am choosing the color that

is the background or foreground colors

and then I am implementing the main

method and setting the size of the text

to 800 and 600 so that's how it works

like you can perform any operations on

accelerator and do leste everything now

let's move further and see the sign of

form which is developed using surf les

GSP and web development tools like HTML

CSS etcetera so I'm just going to create

a basic sign up form and all that you

need is servlets Java server pages

apache tomcat server and cascading style

sheets and Eclipse for Enterprise

Edition it's very easy to develop as

I'll be showing you how

so first let's run the output and check

and then I will explain you the backend


make sure that you run on server

my Tomcat server is starting now

so this is the sign of foam that we have

created you can enter their name I'll

give some email like

13 or older is my option so here in the

signup form you can see your name email

password your age I'll give some

biography like I'm a footballer singer

swimmer exited like this my hobbies I

can give my education everything you can

give like it's not mandatory that it

should be the same thing and the job

role have so many options and web mobile

business and others so I'm very

interested and iOS developer so I'll

give that and interests RN development

design business everything and when I

sign up it says hi Chris welcome to

Erica because the sign of that I have

done got saved so there will be the

output like or where you can see the

details that you have entered in the

backend in this console tab you can see

the details that you have entered that

is your name your email ID your password

your over-30 in your biography your job

role your interest etc so that's all was

there in the form

so you can see here in this form these

are the basic information that has been

given so now let's take a look at the

backend code in the sign up I have

created five files like HTML for

creating a form CSS file to add some

beauty or makeup to the form that we

have created

we have servlet class files like request

post form and person one dot Java class

and then to retrieve the data from the

servlets we have the JSP file and also

we have the Weber Dex ml file to add the

mappings to the servlet and we have JSP

file to retrieve the data from the

servlets so for this front-end that is

your signup form we have used HTML you

can see here that I have linked with CSS

as well that is for giving some make up

to the file that as you can say beauty

to the form that you have created

I'm giving form action as request post

form and Method will be post so here you

can see in the label you have created

like name email password age you're

under 13 or about 13 whatever it is and

then for your profile or your biography

you have created one more label tag and

giving the text ID is equal to bio and

name is equal to user bio and for the

job roles are so many so you have

created a first label for job role and

the first opt group label will be web

and web you have so many options and

again you are closing that and opening

one more up group label that will be

your mobile your business your secure

your other so same things and then for

your interest like this one you can see

you have check boxes over here correct

for that check boxes we have given the

class type value everything like for

development for design for business

everything and last it will be the

submit button that will be your sign up

so this is how your index dot HTML file

will be and now coming to main door CSS

file for each everything I have given

the padding's

like a phone family the color the

maximum bed the margin background

everything even for the first thing that

will be the h1

I have aligned it to center you can see

here I have aligned it to Center and

that is an h1 even for that I have given

the specified color and the phone family

as well and coming down for forum as

well and for all these things I am using

a select type for background border font

size height margin out like padding but

color everything even for the box shadow

as well you can see there's a shadow for

this box it's not just a simple one and

even for the check boxes for buttons

that is present as well for feel set for

legend tax for label for number tax

everything so this will be your main dot

CSS now let's take a look at the servlet

classes so first what I am doing here is

I am extending our HTTP servlet class

correct and I'm using our do post method

and declaring parameters for request and

response I am requesting all the

parameters that is your username email

password age biography job and for your

user interest again the same thing and

then I'm creating an object of person

and trying to retrieve all the details

and then I am trying to request and set

the attribute of my person and then

using the dispatcher I am trying to

request the get request dispatcher from

JSP and obviously in the dispatcher tour

forward you will be having a response

and request both of them so as I have

created the object let's see what was

there in the person in this it's nothing

but it will retrieve all the details

that is I have made everything as

private because I want it to be a

private to the person class and this

class is called as a beam class I will

tell you by I have made a constructor of

person 1 and then using the

parameterised constructor I am trying to

reference and retrieve all the details

you can see like forget name method I'm

returning the name and set name I'm

retrieving again forget email and set

email methods forget password for get

paid set H for bio job roles interest

everything this is nothing but our

defining a constructor and retrieving

the details and

request post form is essential to send a

request and response and then person

bundle Java is essential to retrieve the

details and then as I have told it is

requesting a dispatcher to log in one so

in the login window JSP class I have

imported the beam class that has a

bureaucrat a person one by because I do

Rica is my package and person one is my

class and then I am giving the scope as

request and similarly as I have imported

the beam class and similarly to redirect

it to the next page I have used a small

icon and you can say that it says

welcome to Eureka so this is all about

the GSP and then now coming to the last

file that was web dot XML you have to

add mappings to the file you can give

servlet name like anything but make sure

you give the servlet class name very

properly that is it should be like Ed

Eureka that is your package and your

request post form which is your class

name this should be very correct and

then for URL pattern that this request

post form URL this should be same as the

one which you give in form action tab

that is your request post form URL or

else it will result in an error so this

is all about the signup form I hope you

understood how it works so that's all

for this session if you want to have a

source code or the files of this

explanation and all you can just comment

your email ideas in the comment section

below don't worry we won't expose your

email ids for security purpose we will

contact you and send all the source code

and files to the given email ids that's

all for the session thank you and have a

nice day I hope you have enjoyed

listening to this video please be kind

enough to like it and you can comment

any of your doubts and queries and we

will reply them at the earliest do look

out for more videos in our playlist and

subscribe to Eddie Rica channel to learn

more happy learning