Chat Application Documentation
Chat Application Documentation
CONTENT
Topic
1. Introduction…….………………….......………………….……….……………………...…...3
1.1 Purpose………………….….…...…………………..…………………………...……3
1.2 Project Scope………………………………………..……………………………...…4
1.3 Proposed System………….…………...……………………..……………………….5
1.4 Project Analysys……………………………………………………………………...7
2 Software and Hardware Requirement.….……………………………..……….….. ……….8
3 Literature Survey……………………….….……………………………..…………………..9
3.1 Technical feasibility………………………………………………..…………………9
3.2 Operational feasibility………………………………………………….…………......9
3.3 Economical Feasibility………….…………………………………………………...10
4 System Design……………………………….………………………………………………11
ER DIGRAM…………………………………………………………………………..12
5 System Implementation…………………………….………………………………………..14
6 Code Optimization…………………………………………………………………………..29
7 Testing…………………………………………….…………………………………..……..61
8 Output Screen………………………………………….…………………….……………………....66
9 Conclusion…………………………………..………..……………………………………………....73
10 Future Enhancement……………………………….……………………...………………………….74
11 Bibliography ……………………………………….….……………...……………………………...72
Introduction
Page - 1
CHAT APPLICATION
Chat Application
Report Format
Version : 1.0
Description : First Draft
Created By : Kamalkant Gautam
Date : 4-Dec-17 to 4-Mar-17
1. INTRODUCTION
Page - 2
CHAT APPLICATION
Chat Application is used basically for chatting purpose with the remote clients or users on Internet
or local networks. Here in this project a java client / server combination is used to chat with remote users.
When aClient wants to chat with a user on a remote host, he sends a request to the Server with a
Identification name like chat-id, the server responds to the request by identifying the client-id which
is already registered in the server domain and when matched his request is granted and the client can begin to
chat with the remote users present on the internet or local network.
This project is supported completely by client/server model. A server is anything that has some
resource that can be shared.A client issimply any other entity that wants to gain access to a particular server.
The program's premier feature is its whiteboard drawing utility.
You can draw freehand, do circles, squares, lines, text, or paste image files to thecanvas.Users can interact
publicly with everyone else on the server, or they can chat/draw privately using java Chat's "whisper
mode".
Users can create andmanage chat rooms, which can be either "public" or "private". The server will also
store and manage answering machine-style messages for users who aren't online,and instant messages can be
sent to those who are. Additionally, users who aren’t watching their screens can be paged with sound.
1.1 Purpose
The reason the queen is more powerful than a combination of a rook and bishop, even though
they control the same number of squares, is twofold. First, the queen is a more mobile unit than
the rook and bishop, as the entire power of the queen can be transferred to another location in
one move, while transferring the entire firepower of a rook and bishop requires two moves.
Second, the queen is not hampered by the bishop's inability to control squares of the opposite
color to the square on which it stands. A factor in favor of the rook and bishop is that they can
attack (or defend) a square twice, while a queen can only do so only once, but experience has
shown that this factor is usually less significant than the points favoring the queen.
The queen is at her most powerful when the board is open, when the enemy king is not well-
defended, or when there are loose (i.e. undefended) pieces in the enemy camp. Because of her
long range and ability to move in multiple directions, the queen is well-equipped to
execute forks. Compared to other long range pieces (i.e. rooks and bishops) the queen is less
restricted and more powerful also in closed positions.
Page - 3
CHAT APPLICATION
Where attempts are made to reduce shape outlines which are many pixels thick to outlines which
Add in edge points where they should be reported but have not been.
The program is called Chat, when you are Chatting, everything you type will instantly be transmitted
around the world to other users that might be watching their terminals at the time. Currently most of
the current Chat applications are text based and few are capable of transferring tiny images, but there lacks chat
system for the technical people who can chat as well as they can represent their ideas in the form of drawing
the pictures online. Many vendors distribute even these technologies separately but to obtain these features at
one system will be the haunting task. So what should we do and how should we solve the problem that even
the technical people are benefited by this chatting technology. Through current chatting technologies we are
able to send only text Based messages to people and tiny images, but this type of chatting is not helping the
technical people to work efficiently when the question of sending big pictures like say business plans
to the customers that is the business clients to approve of the plan or the client project, imagine big business
Page - 4
CHAT APPLICATION
plans and deals getting approved through chatting and large business projects started, how beneficial it will be
to the technical people as well the client on the other side.
To solve the inconveniences as mentioned above, an CHATTING ´is proposed. The proposed systems
premier feature is its whiteboard drawing utility. You can draw freehand, do circles, squares, lines,
text, or paste image files to the canvas. This is ideal when users want to "sketch" concepts for one another.
This feature of ³INTRANET CHATTING can be a boon for the technical people who want to share their
ideas or concepts in the pictorial form. This system includes the facilities of traditional chat servers
and clients like providing a window for each Other user, Whisper chat, multiple chat rooms etc. With the help
of the µWHITEBOARD drawing utility now the technical people can carry out their tasks easily
and can share their big picture plans regarding their business to the clients, exchange ideas and concepts and
many more things, basically exchange as well as share the information along with the using the
drawing utility even long conversations can be made between two users which may be important business
meetings or deals to be sanctioned and all this is carried out with the support of applets with the
help of image based web menu images can be transferred.
Page - 5
CHAT APPLICATION
The Architecture of the Chess Queen Game on a grid infrastructure consists of the three
main components. They are:-
Display Chess Board
Perform The Action On-Click
Output Interface
Page - 6
CHAT APPLICATION
SERVER:
The first and foremost problem is to find the server. We should identify the program in the server
which processes the clients request. Administrator Client who will be acting as a super user. Creating private
room with the password facility to enable private chats with the users online. The server is always waiting for
clients requests .The clients come and go down but the server remains the same.
CLIENT:
Should be able to send message to anybody in the room with clients unique chat name created in the server for
chatting purpose. Should be provided with the drawing tools like free hand, rectangles, ovals, lines and also
sending text messages over the room . In all the network applications, we find two sort program where
the first i.e., server sends the information and the second i.e., client receives the information.
Page - 7
CHAT APPLICATION
Page - 8
CHAT APPLICATION
INTRODUCTION
A feasibility study is a high-level capsule version of the entire System analysis and Design
Process. The study begins by classifying the problem definition. Feasibility is to determine if it’s
worth doing. Once an acceptance problem definition has been generated, the analyst develops a
logical model of the system. A search for alternatives is analyzed carefully. There are 3 parts in
feasibility study.
Proposed project is beneficial only if it can be turned into information systems that will meet
the organizations operating requirements. Simply stated, this test of feasibility asks if the
system will work when it is developed and installed. Are there major barriers to
Implementation? Here are questions that will help test the operational feasibility of a project:
Is there sufficient support for the project from management from users? If the current
system is well liked and used to the extent that persons will not be able to see reasons for change,
there may be resistance.
Page - 9
CHAT APPLICATION
Are the current business methods acceptable to the user? If they are not, Users may
welcome a change that will bring about a more operational and usefulsystems.
Have the user been involved in the planning and development of the project?
Early involvement reduces the chances of resistance to the system and in general and
increases the likelihood of successful project.
Since the proposed system was to help reduce the hardships encountered. In the existing
manual system, the new system was considered to be operational feasible.
Page - 10
CHAT APPLICATION
4 SYSTEM DESIGN
The design is a solution, the translation of requirement into ways of meeting them. The
design will determine the success of the system. Based on the proposed system objectives, the
major modules are identified and the operations to be carried out are determined. In the design
phase of the system the user interaction screen, data base tables, inputs, outputs and screen are
designed by using all the necessary fields in a compact manner. The redundancy and duplication
of fields are avoided.
System design involves first logical design and then physical constructions of the system.
After logical design, a detailed specification of the system, which describes the inputs, outputs,
files are developed. During the design phase of the system the following factors are considered.
Data Floors – the movement of data into, around and out of the system.
The importance of software design can be stated with a single word quality. Design is placed
where quality is fostered in software development. Design is the only way whose requirements
are actually translated into a finished software product or system.
ER DIGRAM
Page - 11
CHAT APPLICATION
DFD
Page - 12
CHAT APPLICATION
Page - 13
CHAT APPLICATION
The input design is the link that ties information system into the world of its users. Input design
consist of developing specific procedures for data preparation, steps necessary to put the
transaction data in the form that is usable for computer processing. Main objectives that guides in
the input design stages are:
Controlling errors
The accuracy of the output depends on the accuracy of the input and its processing. Thus, for this
proposed system, the input design is in the format of web pages for the user in format of form for
the administrator.
Validation checks are to be built in the system to avoid any error entries from the users. Hence
the input design is the process of converting user-oriented inputs to a computer based format. So,
input interface design takes an important role in controlling the errors
Customized messages are given in place of system messages, while the data manipulation is
being carried out. Enforcing integrity, data validation procedures are done in such a way that
end-user is free such daily core. There for, the input interface design should be made in such a
way that it can be easily understandable to the user by using meaningful and appropriate words.
Page - 14
CHAT APPLICATION
Computer output is the most important and direct source of information to the administrator.
Efficient, intelligible output design should improve the systems relationship with the appraisal. A
major form output, reports, is a hard copy from printer. When designing output, system analyst
must accomplish the following.
Decide whether to display, print the information and select the output medium
Page - 15
CHAT APPLICATION
5. SYSTEM IMPLEMENTATION
The term Implementation has different meanings ranging from the conversation of a basic
application to a complete replacement of a computer system. The procedures however, are
virtually the same. Implementation includes all those activities that take place to convert from
old systems to new.
The new system may be totally new replacing an existing manual or automated system or
it may be major modification to an existing system. The method of implementation and time
scale to be adopted is found out initially. Neat the system is test properly and at the same time
the users are trained in the new procedure. Proper implementation is essential to provide a
reliable system to meet organization requirement.
Successful and efficient utilization in the system can be achieved only through proper
implementation of the system in the organization. So implementation phase is also important like
other phases such as analysis, design, coding and testing.
Careful planning
Getting complete feedback during test run and ensuring everything in perfect for the final
change over.
Page - 16
CHAT APPLICATION
Hardware Specification
RAM : 512MB
Software Specification
Language: JAVA
JAVA
Java was developed at Sun Microsystems. Work on Java initially began with the goal of
creating a platform- independent language and OS for consumer electronics. The original intend
was to use C++, but as work progressed in this direction, developers identified that creating their
own language would serve them better. The effort towards consumer electronics led the Java
team, then known as First Person Inc., towards developing b/w and s/w for the delivery of video-
on- demand with Time Warner.
Unfortunately (or fortunately for us) Time Warner selected Silicon Graphics as the
vendor for video-on-demand project. This set back left the First Person team with an interesting
Page - 17
CHAT APPLICATION
piece of s/w (Java) and no market to place it. Eventually, the natural synergies of the Java
language and the www were noticed, and Java found a market.
Today Java is both a programming language and an environment for executing programs
written in Java Language. Unlike traditional compilers, which convert source code into machine
level instructions, the Java compiler translates Java source code into instructions that are
interrupted by the runtime Java Virtual Machine. Java is an interpreted language.
Java is the first programming language designed from ground up with network
programming in mind. The core API for Java includes classes and interfaces that provide
uniform access to a diverse set of network protocols. As the Internet and network programming
have evolved, Java has maintained its cadence. New APIs and toolkits have expanded the
available options for the Java network programmer.
Why Java?
In one of their early papers about the language, Sun described Java as follows: Java : A
simple, object oriented, distributed, interpreted, robust, secure, architecture neutral, portable,
high-performance, multi threaded and dynamic language.
Sun acknowledges that this is quite a string of buzzwords, but the fact is that, for the most
part, they aptly describe the language. In order to understand why Java is so interesting, let’s take
a look at the language features behind the buzzwords.
i) OBJECT – ORIENTED
output (the java.io package), and classes that support networking functionality (the java.net
package). Most things in Java are objects; the primitive numeric, character and the Boolean
types are the only exceptions. Strings are represented by objects in Java, as are other
important language constructs like threads. A class is the basic unit of compilation and of
execution in Java; all Java programs are classes. For a complete description of the object-
oriented features of Java, The object oriented language used to create executable contents
such as applications and applets.
ii) INTERPRETED
Java is an interpreted language: the Java compiler generates byte-codes for the Java
Virtual Machine (JVM), rather that native machine code. To actually run a Java program,
you use the Java Interpreter to execute the compiled byte-codes. Because Java byte-codes are
platform-independent, Java programs can run on any platform that the JVM (the interpreter
and run-time system) has been ported to. In an interpreted environment, the standard “link”
phase of program development pretty much vanishes. If Java has a link phase at all, it is only
the process of loading the new classes into the environment, which is an incremental, light
weight process that occurs at run-time.
Because Java programs are compiled to an architecture neutral byte-code format, a Java
application can run on any system, as long as that system implements the Java Virtual
Machine. This is a particularly important for applications distributed over the internet or
heterogeneous networks. But the architecture neutral approach is useful beyond the scope of
network-based applications. As an application developer in today’s software market, you
probably want to develop versions of your application that can run on PCs, Macs and UNIX
workstations. The fact that Java is interpreted and defines a standard, architecture neutral,
byte-code format is one big part of beingportable. But Java goes even further, by making sure
that there are no “implementation-dependent” aspects of the language specification.
Page - 19
CHAT APPLICATION
Java is a dynamic language. Any Java class can be loaded into a running Java interpreter
at any time. These dynamically loaded classes can be the dynamically instantiated. Native
code libraries can also be dynamically loaded. Classes in Java are represented by the Class;
you can dynamically obtain information about a class at run-time. Java is also called a
distributed language. This means, simply, that it provides a lot of high-level support for
networking. In Java 1.1, the Remote Method Invocation (RMI) API allows a Java program to
invoke methods of remote Java objects, as if they were local objects. The distributed nature
of Java really shines when combined with its dynamic class loading capabilities. Imagine.
When multi-media word processor written in Java program is asked to display some type of
data that it has never encountered before, it might dynamically download a class from the
network that can parse the data, and then dynamically download another class that can
display the data within a compound document. A program like this uses distributed resources
on the network to dynamically grow and adapt to the needs of its user.
v) SIMPLE
Java is a simple language. The java designers were trying to create a language that a
programmer could learn quickly, so the number of language constructs has been kept
relatively small. In order to keep the language both small and familiar, the Java designers
removed a number of features available in C and C++. Java does not use header files and it
eliminates the C preprocessor. Java also eliminates the operator overloading and multiple
inheritance features of C++. Java does not use pointers. Since Java does not have structures,
and arrays and strings are objects, there’s no need for pointers. Java automatically handles
the referencing and dereferencing of objects for you. Java also implements automatic garbage
collection, so you don’t have to worry about dangling pointers, invalid pointer references,
and memory leaks, so you can spend your time developing the functionality of your
programs.
vi) ROBUST
Page - 20
CHAT APPLICATION
Java has been designed for writing highly reliable or robust software. Java certainly
doesn’t eliminate the need for software quality assurance; it’s still quite possible to write
buggy software in Java. Java is strongly typed language, which allows for extensive compile-
time check for potential type-mismatch problems. Java requires explicit method declarations.
These stringent requirements ensure that the compiler can catch method invocation errors,
which leads to more reliable programs. Lack of pointers and pointer arithmetic increases the
robustness of Java programs by abolishing an entire class of pointer – related bugs. Similarly,
all accesses to arrays and strings are checked at run-time to ensure that they are in bounds,
eliminating the possibility of over writing memory and corrupting data. Casts of objects from
one type to another are also checked at runtime to ensure that they are legal. Java’s automatic
garbage collection prevents memory leaks and another pernicious bug related to memory
allocation and de location. Exception handling is another feature in Java that makes for more
robust programs. An exception is a signal that some sort of exceptional condition.
vii) SECURE
One of the most highly touted aspects of Java is that it’s a secure language. This is
especially important because of the distributed nature of Java. Without an assurance of
security, you certainly couldn’t want to download code from a random site on the internet
and let it run on your computer. Yet this is exactly what people do with Java applets every
day. Java was designed with security in mind, and provides several layers of security controls
that protect against malicious code, and allow user to comfortably run untrusted programs
such as applets. At the lowest level, security goes hand in hand with robustness. As we have
already seen, Java programs cannot forgepointers to memory, or overflow arrays, or read
memory outside of the bounds of an array or string. This feature is one of Java’s main
defenses against malicious code. By totally disallowing any direct access to memory, an
entire huge, messy class of security attacks is ruled out.
The second line of defense against malicious code is the byte-code verification process
that the Java interpreter performs on any untrusted code it loads. This verification steps
Page - 21
CHAT APPLICATION
ensure that the code is well-formed that it doesn’t over flow or under flow the stack or
contain illegal byte-codes. Another layer of security protection is commonly referred to as
the “sandbox model”: untrusted code is placed in a “sandbox”, where it can play safely,
without doing any damage to the “real world”, or full Java environment. When an applet, or
another untrusted code, is running in the sandbox.
Finally, in Java 1.1, there is another possible solution to the problem of security. By
attaching a digital signature to Java code, the origin of that code can be established in a
cryptographically to secure and unforgivable way. If u has specified that you trust a person or
organization, then code that bears the digital signature of that trusted entity is trusted, even
when loaded over the network, and may be run without the restriction of the sandbox model.
Of course, security isn’t a black & white thing. Just as a program can never be guaranteed to
be 100 % bug-free, no language or environment can be guaranteed 100 % secure. With that
said, however, Java does seem to offer a practical level of security for most applications. It
anticipates and defends against most of the techniques.
Page - 22
CHAT APPLICATION
The runtime environment used to execute the code. It is made up of the java language and
java virtual machine. It is portable and its platform neutral.
It is used by the developers to create java code. They include java compiler, java
interpreter, classes, libraries and applet viewer.
x) JAVA APPLICATION
Java applets are pieces of java code that are embedded in HTML document using the
applet tag. When the browser encounters such code it automatically download it and execute
it.
Page - 23
CHAT APPLICATION
It is a specification to which java codes must be written. All java code is to be compiled
to be used in this nonexistent virtual machine. Writing the code which compiles in JVM
ensures platform independence.
Java was designed with networking in mind and comes with many classes to develop
sophisticated Internet communications. Features such as eliminating memory pointers and by
checking array limits greatly help to remove program bugs. The garbage collector relieves
programmers of the big job of memory management. These and the other features can lead to
a big speed up in program development compared to C/C++ programming.
ADVANTAGES OF JAVA
i) JAVA IS ROBUST
Java is relaxed in terms of type checking in terms of programming errors. Java is strict about
type declarations and does not allow automatic type casting. Also it uses a pointer model that
does not over write memory or corrupt data.
The write-once-Run-Anywhere ideal has not been achieved (tuning for different platforms
usually required), but closer than with other languages.
Page - 24
CHAT APPLICATION
Code is compiled to byte codes that are interpreted by Java virtual machines (JVM). This
provides portability to any machine for which a virtual machine has been written. The two
steps of compilation and interpretation allow for extensive code checking.
All Java applets are treated as untrusted code executing in trusted environment.
Java was written to support distributed applications over the computer networks, it can be
used with a variety of CPU and operating system architecture-neutral object files from Java
code.
v) JAVA IS PORTABLE
a) Java primitive data types and the behavior of arithmetic operations on these data
types are explicitly specified.
b) The Java libraries include portable interfaces for each platform on which the runtime
environment is available,
Page - 25
CHAT APPLICATION
Because java was designed to run on small computers, java system is relatively small for a
programming language. It can run efficiently on PCs with 4MB RAM or more. The Java
interpreter takes up only a few hundred kilo bytes.
Java programs don’t have to worry about memory management. The java system has a built
in program called the garbage collector, which scans the memory and automatically frees the
memory chunks that are not in use.
The linking of data and methods to where they are located is done at run-time.
New classes can be loaded while program is running. Linking is done on the fly. Even if
libraries are recompiled, there is no need to recompile code that uses classes in those
libraries. This differs from C++, which use static binding. This can result in fragile classes
for cases where linked code is changed and memory pointers then point to wrong addresses.
NETBEANS
The NetBeans IDE is a free, open-source Integrated Development Environment for software
developers. The IDE runs on many platforms including Windows, Linux, Solaris and the
MacOS. The NetBeans IDE provides developers with all the tools they need to create
professional cross-platform desktop, enterprise, web and mobile applications.
Using an Integrated Development Environment (IDE) for developing applications saves you
time by managing windows, settings, and data. Drag-and-drop features make creating
Page - 26
CHAT APPLICATION
graphical user interface (GUI) components or accessing databases easy, and highlighted code
and debugging features alert you to errors in your code.
The NetBeans IDE is open source and is written in the Java programming language. It
provides the services common to creating desktop applications such as window and menu
management, settings storage and is also the first IDE to fully support JDK 5.0 features. The
NetBeans platform and IDE are free for commercial and non commercial use, and they are
supported by Sun Microsystems.
Design Swing GUIn intuitively by dragging and dropping GUI components from a palette
onto a canvas, the click into JLabels, JButtons, JTextFields and edit the text directly in place.
You can even use the GUI builder to prototype GUIs right in front of customers. The
NetBeans IDE comes with built-in support for GUI localization and accessibility.
Create a complete functional JSF page for manipulating data from a database in a few steps.
Supports Java Server Faces (JSF), Persistence Units, Struts, and the Java Server Pages
Standard Tag Library (JSTL). Comes with a visual editor for development descriptors and
HTTP monitor to debug web applications.
Use Blueprints, templates and wizards to quickly create Enterprise Java Beans (EJB 3) and
JAX-WS web services. Full support for Java EE 1.3, 1.4 and 1.5 standards.
Page - 27
CHAT APPLICATION
Version control is tightly integrated into the IDE’s workflow: The IDE recognizes your
existing CVS working directories automatically. Use the built-in CVS or get the Subversion
module from the Update Center.
v) DEVELOPER COLLABORATION
With NetBeans Developer Collaboration (available from the Update Center), you share
whole projects and files in real time over the network. Allow your co-workers to make
remote changes and watch them type and run your application. Review your partners work
and send instant messages in plain text, XML, HTML, or Java complete with syntax
highlighting.
The language-aware editor indents, completes, and syntax-highlights your source code. It
parses your code live, matches words and brackets, marks errors, and displays hints and
javadoc. The editor can be fully customized and split vertically or horizontally, and offers
well integrated Refactoring, Debugging and JUnit testing.
Enterprise manager is a window management console to create new data base, users,
security restrictions triggers, procedures, rules etc.. it gives a GUI based design with security.
It allows login for valid users, user can create data bases and users using wizard with good
ease. It gives a tree structure like windows explorer and navigation is very easy. It also
allows to creating a new roles and logins which can be used for security aspects using
enterprise manager we import and export data base from or to their RDBMS.
Query analyzer is another tool with SQL Server, which extends the capabilities of ANSI
standard for SQL. If is an application that recognize and execute SQL commands and the
specialized T-SQL commands that can be used to create data base objects using SQL
command
Page - 28
CHAT APPLICATION
Page - 29
CHAT APPLICATION
package ChatClient;
import javax.swing.*;
import java.net.*;
public ChatJPanel1() {
initComponents();
}
add(jPanel1);
jPanel1.setBounds(10, 30, 420, 250);
}// </editor-fold>
f.setContentPane(new ChatJPanel1());
f.setBounds(10, 10, 450, 325);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
DatagramSocket ds = new DatagramSocket();
String a = new String();
if (jCheckBox1.isSelected()) {
a = "ON";
} else {
a = "OFF";
}
String str = jTextField1.getText() + "," + jPasswordField1.getText() + "," + a;
byte arr[] = str.getBytes();
InetAddress ia = InetAddress.getByName(MainConstants.SERVER_IP);
DatagramPacket dp = new DatagramPacket(arr, arr.length, ia,
MainConstants.CONNECTION_PORT);
ds.send(dp); // TODO add your handling code here:
byte brr[] = new byte[100];
DatagramPacket dp1 = new DatagramPacket(brr, brr.length);
ds.receive(dp1);
String str1 = new String(dp1.getData(), 0, dp1.getLength());
str1 = str1.trim();
if (str1.equals("CONNECTED")) {
JOptionPane.showMessageDialog(this, "You Are Connected");
JFrame f1 = new JFrame("Chatting Application!! User : " + jTextField1.getText());
f1.setContentPane(new ChatJPanel3(jTextField1.getText(), ds));
f1.setBounds(10, 10, 580, 480);
f1.setVisible(true);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(false);
} else if (10 < 10) {
JOptionPane.showMessageDialog(this, "User Already Exists Or Invalid Password");
System.exit(0);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Unable to List to Port");
}
Page - 32
CHAT APPLICATION
package ChatClient;
import java.io.InputStream;
import javax.swing.*;
import java.util.*;
import java.net.*;
import java.sql.*;
Class.forName(pro.getProperty("drivername")).newInstance();
con = DriverManager.getConnection(url, userName, password);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Unable to List to Port" + e.toString());
}
receiver.start();
communicator.start();
initComponents();
}
if (str.startsWith("REMOVE")) {
String username = str.substring(str.indexOf(":") + 1);
for (int i = 0; i < users.size(); i++) {
User u = (User) users.elementAt(i);
Page - 34
CHAT APPLICATION
if (str.startsWith("SENDALL")) {
String msg = str.substring(str.indexOf(":") + 1);
jTextArea1.append(msg + "\n");
for (int i = 0; i < users.size(); i++) {
User u = (User) users.elementAt(i);
InetAddress ip = u.getIp();
int port = u.getPort();
byte arr[] = str.getBytes();
jTextArea1.setCaretPosition(jTextArea1.getText().length());
DatagramPacket dp1 = new DatagramPacket(arr, arr.length, ip, port);
ds1.send(dp1);
}
}
if (str.startsWith("PERSONAL")) {
int aa = str.indexOf(":");
int bb = str.indexOf(":", aa + 1);
int cc = str.indexOf(":", bb + 1);
String from = str.substring(aa + 1, bb);
String to = str.substring(bb + 1, cc);
String msg = str.substring(cc + 1);
jTextArea1.append("From : " + from + " to " + to + " Message : " + msg + "\n");
for (int i = 0; i < users.size(); i++) {
User u = (User) users.elementAt(i);
InetAddress ip = u.getIp();
int port = u.getPort();
byte arr[] = str.getBytes();
String un = u.getUserName();
Page - 35
CHAT APPLICATION
jTextArea1.setCaretPosition(jTextArea1.getText().length());
if (un.equals(to)) {
DatagramPacket dp1 = new DatagramPacket(arr, arr.length, ip, port);
ds1.send(dp1);
}
}
}
} catch (Exception e) {
JOptionPane.showMessageDialog(ChatJPanel2.this, "Unable to Communicate");
}
}
}
}
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Unable to Receive Packet");
}
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTextArea2.setColumns(20);
jTextArea2.setRows(5);
jScrollPane2.setViewportView(jTextArea2);
jScrollPane3.setViewportView(jList1);
add(jPanel1);
jPanel1.setBounds(20, 50, 230, 310);
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 284,
Short.MAX_VALUE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 262,
Short.MAX_VALUE)
.addContainerGap())
);
add(jPanel2);
jPanel2.setBounds(260, 50, 320, 310);
add(jTextField1);
jTextField1.setBounds(20, 370, 310, 30);
}// </editor-fold>
package ChatClient;
import javax.swing.*;
import java.util.*;
import java.net.*;
public ChatJPanel3() {
initComponents();
}
communicator.start();
byte b[] = "USERS".getBytes();
InetAddress ia = InetAddress.getByName(MainConstants.SERVER_IP);
DatagramPacket dp = new DatagramPacket(b, b.length, ia,
MainConstants.COMMUNICATION_PORT);
ds.send(dp);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Unable to List to Port");
}
while (true) {
byte b[] = new byte[256];
DatagramPacket dp = new DatagramPacket(b, b.length);
try {
ds.receive(dp);
String str = new String(dp.getData(), 0, dp.getLength());
str = str.trim();
System.out.println(str);
if (str.startsWith("USERS")) {
String s1 = str.substring(str.indexOf(":") + 1);
if (!dm.contains(s1)) {
dm.addElement(s1);
}
}
if (str.startsWith("REMOVE")) {
String username = str.substring(str.indexOf(":") + 1);
dm.removeElement(username);
}
if (str.startsWith("SENDALL")) {
String text = str.substring(str.indexOf(":") + 1);
jTextArea1.append(text + "\n");
jTextArea1.setCaretPosition(jTextArea1.getText().length());
}
if (str.startsWith("PERSONAL")) {
char flag = 'n';
int aa = str.indexOf(":");
Page - 41
CHAT APPLICATION
class PersonalUsers {
Page - 42
CHAT APPLICATION
public PersonalUsers() {
}
add(jButton3);
jButton3.setBounds(40, 350, 150, 30);
jScrollPane3.setViewportView(jList1);
add(jPanel1);
jPanel1.setBounds(10, 40, 220, 300);
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
Page - 45
CHAT APPLICATION
jScrollPane1.setViewportView(jTextArea1);
add(jPanel2);
jPanel2.setBounds(240, 40, 310, 300);
add(jTextField1);
jTextField1.setBounds(60, 390, 430, 30);
}// </editor-fold>
Page - 47
CHAT APPLICATION
import java.net.*;
import javax.swing.*;
String me;
String username;
DatagramSocket ds;
initComponents();
}
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
add(jScrollPane1);
jScrollPane1.setBounds(10, 10, 400, 230);
add(jTextField1);
jTextField1.setBounds(10, 250, 300, 30);
}// </editor-fold>
Page - 49
CHAT APPLICATION
Page - 50
CHAT APPLICATION
package ChatClient;
public SplashPanel() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
add(jLabel2);
jLabel2.setBounds(290, 214, 140, 40);
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JProgressBar jProgressBar1;
// End of variables declaration
}
package ChatClient;
import java.net.*;
String UserName;
String Passward;
InetAddress ip;
int Port;
public User() {
}
//Server
package vij_gam;
Page - 53
CHAT APPLICATION
import java.io.*;
import java.net.*;
public server(){
System.out.println("CHAT SERVER");
}
while(true){
try{
user1=new user(server.accept(),"user1");
System.out.println("client 1 ket noi thanh cong");
//user1.start();
user2=new user(server.accept(),"user2");
System.out.println("client 2 ket noi thanh cong");
while(true){
user1.start();
user2.start();
}
}
catch(Exception e){}
}
}
catch(EOFException e){
System.out.println("Client ket thuc ket noi");
}
catch(IOException e){
e.printStackTrace();
}
}
userB.getObjectOutputStream().writeObject(dulieu);
//}
}
catch(Exception e){}
Page - 55
CHAT APPLICATION
}
public void run(){
//chuyen thong tin tu client nay sang client kia
while(true){
if(name.equals("user1")){
chuyen(this,user2);
}else{
chuyen(this,user1);
}
}
Page - 56
CHAT APPLICATION
7. TESTING
The purpose of testing is to discover errors. Testing is the process of trying to discover every
conceivable fault or weakness in a work product. It provides a way to check the functionality of
components, sub assemblies, assemblies and/or a finished product. It is the process of exercising
software with the intent of ensuring that the software system meets its requirements and user
expectations and does not fail in an unacceptable manner. There are various types of test. Each
test type addresses a specific testing requirement.
TYPES OF TESTS
Unit Testing
Unit testing involves the design of test cases that validate that the internal program logic is
functioning properly, and that program input produces valid outputs. All decision branches and
internal code flow should be validated. It is the testing of individual software units of the
application .it is done after the completion of an individual unit before integration. This is a
structural testing, that relies on knowledge of its construction and is invasive. Unit tests perform
basic tests at component level and test a specific business process, application, and/or system
configuration. Unit tests ensure that each unique path of a business process performs accurately
to the documented specifications and contains clearly defined inputs and expected results.
Page - 57
CHAT APPLICATION
Integration Testing
Integration tests are designed to test integrated software components to determine if they
actually run as one program. Testing is event driven and is more concerned with the basic
outcome of screens or fields. Integration tests demonstrate that although the components were
individually satisfaction, as shown by successfully unit testing, the combination of components is
correct and consistent. Integration testing is specifically aimed at exposing the problems that
arise from the combination of components.
System Testing
System testing ensures that the entire integrated software system meets requirements. It tests a
configuration to ensure known and predictable results. An example of system testing is the
configuration oriented system integration test. System testing is based on process descriptions
and flows, emphasizing pre-driven process links and integration points.
Functional Testing
Functional tests provide a systematic demonstration that functions tested are available as
specified by the business and technical requirements, system documentation, and user manuals.
Page - 58
CHAT APPLICATION
data fields, predefined processes, and successive processes must be considered for testing.
Before functional testing is complete, additional tests are identified and the effective value of
current tests is determined.
This method is used when knowledge of the specified function that a product has been design to
perform is known. The concept of black box is used to represent a system hose inside working’s
are not available to inspection. In a black box the test item is eaten as “Black”, since its logic is
unknown is what goes in and what comes out, or the input and output.
In black box testing, we try various inputs and examine the resulting outputs. The black box
testing can also be used for scenarios based test .In this test we verify whether it is taking valid
input and producing resultant out to user. It is imaginary box testing that hides internal workings.
In our project valid input is image resultant output well structured image should be received.
White box testing is concern with testing implementation of the program. The intent of structural
testing is not to exercise all the inputs or outputs but to exercise the different programming and
data structures used in the program. Thus structure testing aims to achieve test cases that will
force the desire coverage of different structures. Two types of path testing are:
1. Statement testing
2. Branch testing
Page - 59
CHAT APPLICATION
Statement Testing
The main idea of statement testing coverage is to test every statement in the objects method
by executing it at least once. However, realistically, it is impossible to test program on every
single input, so you never can be sure that a program will not fail on some input.
Branch Testing
The main idea behind branch testing coverage is to perform enough tests to ensure that every
branch alternative has been executed at least once under some test. As in statement testing
coverage, it is unfeasible to fully test any program of considerable size.
UNIT TESTING
Unit testing is usually conducted as part of a combined code and unit test phase of the
software lifecycle, although it is not uncommon for coding and unit testing to be conducted as
two distinct phases.
Page - 60
CHAT APPLICATION
Field testing will be performed manually and functional tests will be written in detail.
Test objectives
Features to be tested
INTEGRATION TESTING
Software integration testing is the incremental integration testing of two or more integrated
software components on a single platform to produce failures caused by interface defects.
The task of the integration test is to check that components or software applications, ex.
components in a software system or one step up software applications at the company level -
interact without error.
Test Results: All the test cases mentioned above passed successfully. No defects encountered.
Page - 61
CHAT APPLICATION
8. OUTPUT SCREENS
The following shows the series of output screens and how the actual process of implementing
The first and the home page of our optical character recognition system looks as shown in
figure 8.1.It provides an interface to the user such that the user can access any module that is
present in this software from this page itself. The page is as shown below:-
1. Sever
2. Client
Page - 62
CHAT APPLICATION
Server Pages
Page - 63
CHAT APPLICATION
Page - 64
CHAT APPLICATION
Page - 65
CHAT APPLICATION
Client Pages
Page - 66
CHAT APPLICATION
Page - 67
CHAT APPLICATION
9. CONCLUSION
Page - 68
CHAT APPLICATION
What does the future hold for Chess Queen Game? Given enough entrepreneurial designers and
sufficient research and development dollars, Chess Queen Gamecan become a powerful tool for future
data entry applications. However, the limited availability of funds in a capital-short environment could
restrict the growth of this technology. But, given the proper impetus and encouragement, a lot of benefits
10.FUTURE ENHANCEMENTS
Page - 69
CHAT APPLICATION
There is always a room for improvements in ay software pack. however good and efficient it
may be done. But the most network should be flexible to accept further modification. Right now
we arejust chat with text communication. In future this software run be extended to include
features such as :
Page - 70
CHAT APPLICATION
11. BIBILOGRAPHY
Java AWT
By John Zukowski
Java Swings
By Dietel & Dietel
Page - 71