You are on page 1of 60

A PROJECT REPORT ON

CHAT SERVER
Submitted in the partial fulfillment of the requirement for the award of degree of

MASTER OF COMPUTER APPLICATION


2005 2006

Guide By: Mr. AMIT GUPTA

Developed By: MOHIT KUMAR Roll No.: 0402914049 TARUN KUMAR Roll No.: 0402914107

Submitted to:

KIET SCHOOL OF COMPUTER APPLICATION


KRISHNA INSTITUTE OF ENGINEERING & TECHNOLOGY, GHAZIABAD UP TECHNICAL UNIVERSITY, LUCKNOW

CANDIDATES DECLARATION

I hereby declared that the work presented in the dissertation titled Chat Server in partial fulfillment of requirement for the award of degree of Masters of Computer Application submitted in KIET SCHOOL OF COMPUTER APPLICATION , KRISHNA INSTITUTE OF ENGINEERING & TECHNOLOGY, GHAZIABAD, is authentic record of my work carried out during the period from 15th Feb,2006 to 28th Apr,2006.

Date: Place

(Mohit Kumar) (Tarun Kumar)

ACKNOWLEDGEMENT
With immense pleasure, I take this opportunity to express my sincere thanks and deep gratitude to all those people who extended their wholehearted co-operation and their help for me in completing this project successfully. I express my humble to Mr. Amit Gupta and Miss. Nimisha goel, for his valuable guidance and inspiration in my taking up this project. I think that with out him, I couldnt complete my project.

I am personally very thankful to Mr. Parshant Aggarwal and Miss. Sangeeta Arora for providing me the information about java and help me in the development of Chat Server. At last but not the least I give my hearty thanks to my family members and well wishers who supported me morally and encouragement constructive criticism given to me during the project period.

DATE

( Mohit Kumar)

( Tarun Kumar)

Part 1: Introduction Hardware and Software used Part 2: Data Flow Digrams ( DFDs ) Entity Reltionship Diagrams(ER Diagrams) Part 3: History of JAVA Remote Method Invocation (RMI) Part 4: Database Used Part 5: Screen Shots Part 6: Coding Part 7: Progress Table Conclusion Bibliography

Part 1

Introduction Hardware and Software used

SOFTWARE DEVELOPMENT LIFE CYCLE


INTRODUCTION The SDLC includes ten phases during which defined IT work products are created or modified. The tenth phase occurs when the system is disposed of and the task performed is either eliminated or transferred to other system. The tasks and work products for each phase are described in subsequent chapters. Not every project will require that phases be sequentially executed. However, the phases are interdependent. Depending upon the size and complexity of the project, phases may be combined or may overlap. The goals of this SDLC approach are to: Deliver quality systems which meet or exceed customer expectations when promised and within cost estimates. Provide a framework for developing quality system using an identifiable, measurable, and repeatable process. Establish a project management structure to ensure that each system development project is effectively managed throughout its life cycle. Identify and assign the roles and responsibilities of all involved parties, including functional and technical managers, throughout the system development life cycle.

Ensure that system subsequently satisfied.

development

requirements

are

well

defined

and

The system Development Life Cycle methodology will help to achieve these goals by: Establishing appropriate levels of management authority to provide timely direction, coordination, control, review, and approval of the system development project. Ensuring project management accountability. Documenting requirements and maintaining trace ability of those requirements throughout the development and implementation process. Ensuring that projects are developed within the current and planned information technology infrastructure. Identifying project risks early and manage them before they become problems.

The SDLC encompasses ten phases:


Initiation phase

The initiation of a system (or project) begins when a business need or opportunity is identified. A project Manager should be appointed to manage the project. This business need is documented in a Concept Proposal. After the Concept Proposal is approved, the System Concept Development phase begins.

System Concept Development Phase Once a business need is approved, the approaches for accomplishing the concept are reviewed for feasibility and appropriateness. The System Boundary Document identifies the scope of the system and requires Senior Official approval and funding before beginning the Planning Phase. Planning Phase The concept is further developed to describe how the business will operate once the approved system is implemented, and to assess how the system will impact employee and customer privacy. To ensure the products and / or services provide the required capability on-time and within budget, projects resources, activities, schedules, tools and reviews are defined. Additionally, security certification and accreditation activities begin with the identification of system security requirements and the completion of a high level vulnerability assessment. Requirements Analysis Phase Functional user requirements are formally defined and delineate the requirements in terms of data, system performance, security, and maintainability requirements for the system. All requirements are defined to a level of detail sufficient for system design to proceed. All requirements need to be measurable and testable and to the business need or opportunity identified in the Initiation Phase. Design Phase The physical characteristics of the system are designed during this phase. The operating environment is established, major subsystems and their inputs and outputs are defined, and processes are allocated to resources. Everything requiring user input or approval must be documented and reviewed by the user. The physical characteristics of the system are specified and a detailed design is prepared. Subsystems identified during design are used to create a detailed structure of the system. Each subsystem is partitioned into one or more design units or modules. Detailed logic specification is prepared for each software module. Development phase The detailed specifications produced during the design phase are translated into hardware, communications, and executable software. Software shall be unit tested, integrated, and retested in a systematic manner. Hardware is assembled and tested. Integration and Test Phase The various components of the system are integrated and systematically tested. The user tests the system to ensure that the functional requirements, as defined in the functional requirements documents, are satisfied by the developed or modified system. Prior to installing and operating the system in a production environment, the system must undergo certification and accreditation activities.

Implementation Phase The system or system modifications are installed and made operational in a production environment. The phase is initiated after the system has been tested and accepted by the user. This phase continues until the system is operating in operating in production in accordance within the defined user requirement. Operations and Maintenance Phase The system operation is ongoing. The system is monitored for continued performance in accordance with user requirements, and needed system modifications are incorporated. The operational system is periodically assessed through In-Process Reviews to determine how the system can be made more efficient and effective. Operations continue as long as the system can be effectively adapted to respond to an organizations needs. When modifications or changes are identified as necessary, the system may reenter the planning phase. Disposition Phase The disposition activities ensure the orderly termination of the system and preserve the vital information about the system so that some or all of the information may be reactivated in the future if necessary. Particular emphasis is given to proper preservation of the data processed by the system, so that the data is effectively migrated to another system or archived in accordance with applicable records management regulations and policies, for potential future access.

INITIATION PHASE:
OBJECTIVE The Initiation Phase begins when management determines that it is necessary to enhance a business process though the application technology. The purposes of the Initiation Phase are to: Identify and validate an opportunity to improve business accomplishments of the organization or a deficiency related to a business need. Identify significant assumptions and constraints on solutions to that need, and Recommend the exploration of alternative concepts and methods to satisfy the need. IT projects may be initiated as a result of business process improvement activities, changes in business function, advances in information technology, or may arise from external sources, such as public law, the organization to initiate the project file cycle. During this phase a Project Manager is appointed who prepares a Statement of Need or Concept Proposal. When an opportunity to improve business/mission accomplishments or to address a deficiency is defined, the Project Manager documents these opportunities in the Concept Proposal. TASK AND ACTIVITIES

The following activities are performed a part of the Initiation Phase. The results of these activities are captured in the Concept Proposal. For every IT project, the agency, the agency should designate a responsible organization and assign those organization sufficient resources to execute the project. Identify the Opportunity to Business Functions Identify a Project Sponsor Form (or appoint) a Project Organization Document the Phase Efforts

CONCEPTUAL PROPOSAL
OBJECTIVE System Concept Development begins when the Conceptual Proposal has been formally approved and requires study and analysis that may lead to System development activities. The review and approval of the Concept Proposal begins the formal studies and analysis of the need in the System Concept Development Phase and begins the life cycle of an identifiable project. TASKS AND ACTIVITIES The following activities are performed as part of the System Concept Development Phase. The results of these activities are captured in four phase documents and their underlying institutional processes and procedures (See Figure).
Study and Analyze the Business Need Plan the Project Form the Project Acquisition Strategy Study and Analyze the Risks

PLANNING PHASE:
OBJECTIVE Many of the plans essential to the success of the entire project are create in this phase; the created plans are then reviewed and update throughout the remaining SDLC phases. In the planning phase, the concept is further developed to describe how the business will Operate once the approved system is implemented and to assess how the system will impact employee and customer privacy. To ensure the products and/or services provides the required capability on-time and within budget, project resources, activities, schedules, Tools, and reviews are defined. Additionally, security certification and accreditation activities begin with identification of system security requirements and the completion of a high-level vulnerability assessment.

TASK AND ACTIVITIES The following tasks are performed as part of the planning phase. The results of these activities are captured in various project plans and solicitation documents. Refine Acquisition Strategy in System Boundary Documents Analyze Project Schedule Create Internal Processes Establish Agreements with Stakeholders Develop the Project Management Plan Develop the System Engineering Management Plan Review Feasibility of System Alternatives Study and Analyze Security Implications Revise Previous Documentation

REQUIREMENT ANALYSIS :
OBJECTIVE The Requirement Analysis Phase will begin when the previous phase documentation has been approved or by management direction. Documentation related to user requirement from the planning phase shell be used as the basis for further user needs analysis and the

Development of detailed user requirements. The analysis may reveal new insights into the Overall information system requirements, and, in such instances, all deliverables should be revised to reflect this analysis. During the Requirement Analysis phase, the system shall be defined in ore detail with regard to system inputs, processes, outputs, and interfaces. This definition process occurs At the function level .The system shall be described in terms of the function to be performed, not in terms of computer programs, files, and data streams. The emphasis in this phase is on determining what function must be performed rather than how to perform those functions. TASK AND ACTIVITIES The following tasks are performed during the Requirements Analysis Phase. The tasks and activities actually performed depend on the nature of the project , Inclusion of tasks for the ,Alternative SDLC work patterns. Analyze and Document Requirements.

First consolidate and affirm the business needs. Analyze the intended use of the system And specify the functional and data requirements. Connect the functional requirements to the data requirements. Defines functional and system requirements that are not easily Expressed in data and process models Refine the high level architecture and logical design to support the system and functional requirement. A logical model is constructed that describes the fundamental processes and data needed to support the desired business functionality. This logical model will show how processes interact and how processes created and use data. These processes will be derived from the activity descriptions provided in the System Boundary Document. Functions and entity types contained in the logical model are extended and refine from those provided in the Concept Development Phase. End-user and business areas experts will evaluate all identified processes and data structures to ensure accuracy, logical consistency, and completeness. An analysis of business activities and data structure perform to produce entity-relationship diagrams, process hierarchy diagrams, process dependency diagrams, and associated documentation. An interaction analysis produce Process logic and action diagrams, definitions of the business algorithms, entity life-cycle diagrams, and entity state change matrices .A detailed analysis of the current technical architecture, application software, and data is conducted to ensure that limitation or Unique requirements have not been overlooked. Include all possible requirements including those for: Functional and capability specifications, including performance, physical characteristics, and environmental conditions under which the software item is to perform; Interfaces external to the software item; Safety specification, including those related to methods of operation and maintenance, environment influences, and personnel injury; Security specification, including those related to compromise of sensitive information; Human-factors engineering, including those related to manual operations, human- equipment interactions, constraints on personnel, and areas needed concentrated human attention, that are sensitive to human errors and training; o Data specification and database requirements

o Installation and acceptance requirement of the delivered software product at the operation and maintenance site(s) o User documentation o User operation and execution requirements o User maintenance requirement

Developed Test Criteria and plans Develop an Interface Control Document Conduct Functional Review Revise Previous Document

DESIGN PHASE:
OBJECTIVE The objective of the Design Phase is to transform the detailed, defined requirements into complete, detailed specifications for the system to guide the work of the Development Phase. The decisions made in this phase address, in detailed, how the system will meet the defined functional, physical, interface, and data requirements. Design Phase activities may be conducted in an iterative fashion, producing first a general system design that emphasizes the functional features of the system, then a more detailed system design that expands the general design by providing all the technical detailed. TASKS AND ACTIVITIES The following tasks are performed during the Design Phase. The tasks and activities actually performed depend on the nature of the project. Guidelines for selection and inclusion of tasks for the Design Phase may be found, Alternate SDLC Work Patterns. Establish the Application Environment Design the Application Develop Maintenance Manual Develop Operational Manual Conduct Preliminary Design Review Design Human Performance Support (Training) Design Conversion/Migration/Transition Strategies Conduct a Security Risk Assessment Conduct Critical Design Review Revise Previous Documentation

DEVELOPMENT PHASE:
OBJECTIVE The objective of the development phase will be to convert the deliverables of the design phase into a complete information system. Although much of the activity in the

development phase addresses the computer programs that make up the system, this phase also puts in place the hardware, software, and communications environment for the system and other important elements of the overall systems. The activities of this phase translate the system design produced in the design phase into a working information system capable of addressing the information system requirements. The development phase contains activities for building the system, testing the system, and conducting functional qualification testing, to ensure the system functional processes satisfy the functional process requirements in the Functional Requirement Document (FRD) At the end of this phase, the system will be ready for the activities of the Integration and Testing Phase. TASKS AND ACTIVITIES Code and Test Software Integration Software

Integration the software units, components and modules. Integration the software units and software components and test in accordance with the integration plan. Ensure that A module satisfies the requirements of the software at the conclusion of the integration activity. Conduct Software Qualification Testing

Conducting qualification testing in accordance with the qualification requirement for the software items. Ensure that the implementation of each software requirement is tested for compliance. Support audit(s), which could be conducted to ensure that: o As-coded software products (such as software item) reflect the design documentation. o The acceptance review and testing requirements prescribed by the documentation are adequate for the acceptance of the software products. o Test data comply with the specification o Software products were successfully tested and meet their specifications o Test reports are correct and discrepancies between actual and expected results have been resolved o User documentation complies with standards as specified The results of the audits shall be documented. If both hardware and software are under development of integration, the audits may be postponed until the System Qualification Testing. Upon successful completion of the audits, if conducted, update and prepare the deliverable software product for System Integration, System Qualification Testing, Hardware Installation, or Software Acceptance Supports as applicable. Also, establish a baseline for the design and code of the software item. Integrate System

Integrate the software configuration items with hardware configuration items, manual operations, and other systems as necessary, into the system. The aggregates shall be tested, as they are developed, against their requirements. The integration and the test results shall be documented. For each qualification requirement of the system, a set of tests, test cases (inputs, outputs, test criteria), and test procedure for conducting System Qualification Testing shall be developed and documented. Ensure that the integration system is ready for System Qualification Testing. Conduct System Qualification Testing

Conduct system qualification testing in accordance with the qualification requirements specified for the system. Ensure that the implementation of each system requirement is tested for compliance and that the system is ready for delivery. The qualification testing results shall be documented. Install Software

Install the software product in the target environment as designed and in accordance with the Installation Plan. The resources and information necessary to install the software product shall be determined and be available. The developer shall assist the acquirer with the set-up activities. Where the installed software product is replacing an existing system, the developer shall support any parallel running activities that are required. Ensure that the software code and databases initialize ,execute, and terminate as specified in the contract. The installation events and results shall be documented. Document Software Acceptance Support

Acceptable review and testing shall consider the results of the Joint Reviews, Audits, Software Qualification Testing, and System Qualification Testing (if performed). The results of the acceptance review and testing shall be documented. The developer shall complete and deliver the software product as specified. The developer Shall provide initial and continuing training and support to the acquirer as specified. Revise Previous Documentation

Revive and update previous phase documentation as needed

2.9 INTEGRATION AND TEST PHASE


OBJECTIVE The objective of this phase is to prove the developed system that the developed system satisfies the requirements defined in the FRD. Several types of tests will be conducted in the phase. First, Subsystem integration tests shall be executed and evaluate by the development team to prove that the program components integrate properly into the subsystems and that the subsystems integrate properly into a application. Next, the testing team conducts and evaluates system tests to ensure the developed system

meets all technical requirements, including performance requirement. Next, the testing team and the security program manager conduct security tests to validate that the access and data security requirements are met. Finally, users participate in acceptance testing to confirm that the developed system meets all user requirements as stated in the FRD. Acceptance testing shall be done in a simulated real user environment with the users using simulating or real target platforms and infrastructures . TASKS AND ACTIVITIS The tasks and activities actually performed depend on the nature of the project. The following tasks should be completed during the integration and test phase . Establish the Test Environment

Establish the various test teams and ensure the test system(s) are ready. Conduct Integration Tests

The test and evaluation team is responsible for creating/loading the test database(s) and executing the integration test(s). This is to ensure that program components integrate properly into the subsystems and the subsystem integrates properly into an application. Conduct Subsystem/System Testing

The test and evaluation team is responsible for creating/loading the test database(s) and executing the system tests. All results should be documented on the test analysis report, test problem report and on the test analysis approval determination. Any field components should be migrated back to the development phase for rework, and the passed components should be migrated ahead for security testing. Conduct Security Testing

The test and evaluation team will again create or load the test databases and execute security (penetration) tests. All tests will be documented, similar to those above. Failed components will be migrated back to the development phase for rework, and passed components will migrate ahead for implementation. Revise Previous Documentation

During this phase, the systems technical lead or the developers will finalize the software development document from the development phase. He/They will also finalize the operations or systems administration manual, user manual, training plan maintenance manual, conversion plan, implementation plan , contingency plan and update the interface control document from the design phase. The project manager should finalize the system security plan and the security risks assessment form the requirement analysis phase and the project management plan from the planning phase. The configuration manager should finalize the configuration management plan from the planning phase. The quality assurance office/person should finalize the quality

assurance plan from the planning phase. And finally, the project manager should finalize the cost benefit analysis and the risk management plan from the system concept development phase.

IMPLEMENTATION PHASE
OBJECTIVE In the phase, the system or system modification are installed and made operational in a production environment. The phase is initiated after the system has been tested and accepted by the user and project manager. Activities in the phase include notification of implementation to end users, execution of the previously defined training plan, Data Entry of Conversion, and post implementation review. This phase continues until the system is operating in production in accordance with the defined user requirements. The new system can fall into three categories, replacement of a manual process, replacement of a legacy system, or upgrade to an existing system regardless of the type of system, all expects of the implementation phase should be followed. This will ensure the smoothest possible transition to the organizations desired goal. TASKS AND ACTIVITIES Task and activities in the implementation phase are associated with certain deliverables described in section 10.3. The task and activities actually performed depend on the nature of the project. A description of these tasks and activities is provided below. Notify Users of New Implementation

The implementation notice should be sent to all users and organizations affected by the implementation. Additionally, it is good policy to make internal organizations not directly affected by the implementation aware of the schedule so that allowances can be made for a disruption in the normal activities of the section. Some notification methods are EMail, Internal Memo to heads of department, Voice Tree Messages. The notice include:

o o o o this phase; and o and phone numbers

The schedule of the implementation; A brief synopsis of the benefits of the new systems; The difference between the new and old system; Responsibilities of end user affected by the implementation during The process to obtain system support, including contact names

Execute Training Plan Perform Data Entry or conversion Install systems Conduct Post implementation review Revise Previous documentation

OPERATION AND MAINTEMANCE:

OBJECTIVE More then half of the life cycle costs are attributed to the operations and maintenance of systems .In this phase, it is essential that all facets of operations and maintenance are performed. The system is being used and scrutinized to ensure that it meets the needs initially stated in the planning phase. Problems are detected and new needs arise. This may require modification to existing code, new code to be developed and/or hardware configuration changes. Providing user support is an ongoing activity. New users will require training and other will require training as well. The emphasis of this phase will be to ensure that the users needs are met and the system continues to perform as specified in the operational environment. Additionally, as operations and maintenance personal monitor the current system they may become aware of better ways to improve the system And therefore make recommendations. Changes will be required to fix problems, possibly add features and make improvements to the system. This phase will continue as long as the system is in use. TASKS AND ACTIVITIES Identify Systems Operations

Operations support is an integral part of the day-to-day operations of the system. In small systems, the same person may do all or part of each task. But in large systems, separate individuals or even separate areas may do each function. The Operations Manual is developed in previous SDLC phases. This documents defines tasks, activities and responsible parties and will need to be updated as changes occur. Systems operations activities and tasks need to be scheduled, on a recurring basis, to ensure that the production environment is fully functional and is performing as specified. The following is a check list of a systems operations key tasks and activities: o Ensure that systems and networks are running and available during the defined hours and operations; o Implement non emergence requests during scheduled outages, as prescribed in the operations manual; o Ensures all processes, manual and automated, are documented in the operating procedures. These processes should comply with the system documentation; o Acquisition and storage of supplies (i.e. paper, toner, taps, removable disks); o Performs backups (day-to-day protection, contingency); o Perform the physical security functions including ensuring adequate UPS, Personal have proper security clearances and proper access privileges etc; o Ensure contingency planning for disaster recovery is current and tested; o Ensure users are trained on current processes and new processes; o Ensure that service level objectives are kept accurate and are monitored; o Maintain performance measurements, statistics, and system logs. Examples of performance measures include volume and frequency of date to be processed in each mode, order and type of operations;

Monitor the performance statistics, report the results and escalate

problems when they occur. Maintained data /Software Administration

Maintained data /Software Administration is needed to ensure that input data and output data and databases are correct and continually checked for accuracy and completeness. This includes ensuring that any regularly scheduled jobs are submitted and completed correctly. Software and databases should be maintained at (or near) the current maintenance level. The backup and recovery processes for databases are normally different Then day-to-day DASD volume backups. The backup and recovery processes of the databases should be done as a data/Software administration tasks by a data administrator. A checklist of data /Software administration tasks and activities are: o Performing a periodic verification /validation of data, correct data related problems; o Performing production control and quality control functions (job submission, checking and corrections); o Interfacing with other functional areas for day-to-day checking/corrections; o Installing, configuring, upgrading and maintaining database. This includes updating processes, data flows, and objects; o Developing and performing data/database backup and recovery routines for data integrity and recoverability. Ensure documented properly in the operations manual; o Developing and maintaining a performance and tuning plan for online process and databases; o Performing configuration/design and audits to ensure software, system, parameter configuration are correct; Identify Problem and Modification Process Maintain System / Software Revise Previous Documentation

Hardware/Software Requirements

As this project is developed in JAVA, which is platform independent, so this software can run within any operating system. This Software needs at least 400 Mhz or hire Processor . RAM required more then 32 MB for best performance, at least 2.1 Hard Disk is required for installing this Software but it will refer on the amount of the Database used for this Software, SVGA, display of 1 MB video memory and color monitor but with this lot of processor power consumed and speed of the system will be very slow. Therefore a realistic hardware and software configuration for this Software is:

Processor Operation System RAM Monitor Hard Disk Printer

: : : : : :

2.4 Ghz Windows 2000 256 MB Any color Monitor 40 GB Laser

Part 2

Data flow Diagram Entity Relationship Diagram

Data Flow Diagram:


A Data Flow Diagram (DFD) is a process-oriented graphical representation of an application system. In the words of Hoofer, George and vocalic (1990), a DFD is a picture of movement of data between external entities and the processes and data stored within a system.

A Data Flow Diagram consists of a series of bubbles joined by lines. The Bubbles represent data transformation and the Lines represent data flow in the system. Data Flow Diagram Notations Process Notation Process A Circle or a Bubble represents a process That transforms incoming data flow into Outgoing data flow. Data Store Notation Data Store An open rectangle or parallel line Represents data store. Data store are Repositories of data in the system. They are sometimes also referred to as files. External Entity External entities are objects outside he system, with which the system -captions. External entities are source & Destination of the systems inputs and Outputs. Data Flow Data flow are the pipeline through which Information flow. Label the arrows with the name of the data moves through it.

External Entity Notation communi-

Data Flow Notation

Start gggS sSSS sssb hjStar

Seprate indow is Goup the message to and opened Chat

Strat the RMI Registry t Is? the server Sendon and Recive

Run the Stop Run The Server from Server For specific person

No

Yes

Entity-Relationship Diagram:
An entity relationship diagram is a graphical representation of an organizations data storage requirements. These are the people, places, things, events and concepts of interest to an organization. In short, anything which an organization needs to store data about.

Entity relationship diagrams are the abstractions of the real word, which simplify the problem to be solved while retaining its essential features. Entity relationship diagrams are used to: Identify the data that must be captured, stored and retrieved in order to support the business activities performed by an organization; and Identify the data required to derive and report on the performance measures that an organization should be monitoring. Entity relationship diagrams have their different components: ATTRIBUTES ENTITIES RELATIONSHIPS

Frequently, a meaningful relationship exists between two different types of entity. For Example: EMPLOYEES work in a DEPARTMENT LAWYERS advise CLIENTS TRUCK is a type of VEHICLE
There are three type of relationship, which can exist between two different entities: One-to-One Relationships One-to-Many Relationships Many-to-One Relationships Many-to-Many Relationships

The basic things that relates to the tables is by the help of Primary key and Foreign key concepts.

Primary Key is defined as that unique key that is unique in the whole table and that cannot be null and duplicate in any circumstances. Foreign Key is defined as the key that is particularly primary key in other table and represent as a field in this current table. Advantages of using Entity-Relationship Diagram:

By the help of Entity-Relationship Diagram, the developer and the customer both have the mutual understanding in between them as they would have the clear cut picture about the various tables and the fields related to their project. This pictorial representation provides the OBJECT MODELING purpose of the develop.

Entity

Entity An entity is an object or concept about which you Want to store information.

Entity

Weak Entity A weak entity is dependent on another entity to exist

Attribute

Attributes Attributes are the properties or characteristics of an Entity. Key Attributes A key attribute is the unique, distinguishing Characteristic of the entity. For example, Students Roll No. might be the Students key attribute. Multi valued attribute A multi valued attribute can have more than one value. For example, an employee entity can have multiple skill values. Derived attribute A derived attribute is based on another attribute. For example, an employees monthly salary is based on the employees annual salary. Relationships Relationships illustrate how to entities share information in the database structure.

Attribute

Attribute

Attribute

Relationship

Relationship

Weak Relationship To connect a weak entity with others, you should

use a weak relationship notation.

id

id

sid

rid

Chat Users

Send and Recive

Chat Message
Type msg flag

id
Typ e

sid
Chat_Message msg

rid

Flag

Send & Reciv e

id

sid Chat_Persona flag l

rid

Part 3

History of JAVA Remote Method Invocation (RMI)

JAVA
History Of Java
Java was conceived by James Gostling,Patric Naughton,Chris Warth,Ed Frank ,and Mike Sheridan at Sun Microsystems,Inc. in 1991.It took 18 months to develop the first working version. This language was initially called Oak but was renamed Java in 1995.

Forces Behind Java


The original impetus of Java as not Internet! Instead, the primary motivation was the need for a platform-independent (that is architectural neutral)language that could be used to create software to be embedded in various electronic devices ,such as microwave ovens nd remote controls. The second force was the World Wide Web. With the emergence of WWW,Java was propelled to the forefront of computer language design, because the Web ,too demanded portable programs.

Java & Internet


The Internet helped catapult Java to the forefront of programming, and Java, in, turn has had profound effect on the Internet. The reason for this is: Java expands the universe of objects that can move about freely in cyberspace.

Applet & Application


Java can be used to create two types of programs: Application and Applet. An Application is a program that runs on your computer; understand the operating system of that computer. An Applet is a Application designed to be transmitted over the Internet and executed by a Javacompatible Web browser.

Security
When we have a java compatible web browser, we can safely download the Java applets by confining a Java program to the Java execution and not allowing it access to other part of computer.

Portability
Many types of computer and operating systems are in use and many are connected through the Internet. For programs to be dynamically downloaded to all various types of platforms connected to the Internet, some means of generating portable code is needed.

ByteCode
The Key that allow java to solve the security and portability problems is that output of a Java compiler is not executable code, rather it is Bytecode.Bytecode is highly optimized set of instruction designed to be executed by Java run-time System,which is called the JVM(Java Virtual Machine).JVM is an interpreter for bytecode.

Translating a java program into bytecode helps makes it much easier to run a java program in a wide variety of platforms. The reason is straightforward:Only the JVM needs to be implemented for each platform.

Remote Method Invocation (RMI)


RMI allow a Java object that executes on one machine to invoke a method that executes on other machine. This is an important feature because it allows you to build distributed applications.

RMI Concept
A java object runs within a Java Virtual Machine (JVM).However ,object used by a J2EE application do not need to run on the same JVM as the J2EE application.This is because a J2EE application and its components can invoke objects located on a different JVM by using the RMI system.

RMI is used to connect together a Client and Server.A Client is an application or component that requires the service of an object to fulfill a request .A Sever creates an object and makes the object available to clients.A client contacts the server to reference and invoke the object by using RMI. A Client locates a remote object by either using RMI naming registry or by passing a string that references the remote object .In either case, RMI returns a reference to the remote object ,which is then invoked by the client as if the object was on the local JVM.

Remote Interface
Server-side object that are invoked by remote clients must implements a remote interface and associated method definitions. The Remote interface is used by clients to interact with the object using RMI communications. A remote interface extends java.rmi.Remote and each method must throw a RemoteException.

RMI Process

Step 1:Enter and compile the source code


javac sourcefilename_client javac sourcefilename_server javac sourcefilename_interface javac sourcefilename_implementation

Step 2:Genrate Stubs and Skeletons


rmic sourcefilename_impl

Step 3:Insatll Files on the Client and Server MAchines Step 4:Start RMIRegistry on the Server Mahine
start rmiregistry

Step 5:Start the Server


java sourcefilename_server

Step 6:Start the Client


java sourcefilename_client

Stub and Skelton


A stub is a java object that reside on the client machine .Its function is to present the same interface as the remote server. Remote methods calls initiated by the client are actually directed to the remote server. The stub works with the other parts of the RMI system to formulate a request that is sent to the remote machine. A Skeleton is a java object that reside on the server machine.It works with the other parts of the RMI system to receive request and perform deserialization and invoke the appropriate code on the server.

Part 4

Data Base Used

Database Used:
Table name: chat_users
Fields: id

Table name: chat_message


Fields: Id sid

rid type msg flag

Table name: chat_personal


Fields: Id sid rid flag

Part 5

Screen Shots

Starting RMI Registry

Starting the Server

Starting The Client

When Client Starts, the following Login Screen will display. The client has to enter his login name and when he/she click OK button, the main window will display. If he/she click on Cancel button then the window will disappear.

Login Window

Once the user login by giving his/her name the following main window will display:

Main Window

Chatting Between two users Group Chatting

Chatting Between two users

Private Chatting ( User 1 )

Private Chatting ( User 2 )

Part 6

Coding

ChatMain.java
import java.rmi.*; public interface ChatMain extends Remote { public String getValue(String sid)throws RemoteException; public String getValue(String sid,String rid)throws RemoteException; public String setValue(String val,String sid)throws RemoteException; public String setValue(String val, String sid, String rid)throws RemoteException; public int setName(String nam)throws RemoteException; public String getName()throws RemoteException; public void removeName(String nam) throws RemoteException; public void setPersonal(String sid,String rid)throws RemoteException; public String getPersonal(String rid)throws RemoteException; }

ChatImp.java
import java.rmi.*; import java.rmi.server.*; import java.sql.*; public class ChatImp extends UnicastRemoteObject implements ChatMain,Runnable { String str,str1; String name; int i; long count,count1; Connection cn; Statement st; Thread th1; public ChatImp() throws RemoteException { super(); str="Welcome to Mohit Bansal's chat Server"; i=0; count=0;count1=0; try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); cn=DriverManager.getConnection("Jdbc:Odbc:mk","scott","tiger"); st=cn.createStatement(); st.executeUpdate("delete from chat_message"); st.executeUpdate("delete from chat_personal"); st.executeUpdate("delete from chat_users"); }catch(Exception e){System.out.println("Error : to access Database : " + e);} th1=new Thread(this,"mkb"); th1.start(); } //-------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------// public void run() { while(true) { try{ // st.executeUpdate("delete from chat_message where flag=1"); st.executeUpdate("delete from chat_personal where flag=1"); Thread.sleep(100000); }catch(Exception es){System.out.println("Error : " + es);} } } //-------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------// public String getValue(String sid) { int id=0; str=""; try{

ResultSet rs=st.executeQuery("select * from chat_message where type='G' and flag=0 and rid like '"+sid+"'"); while(rs.next()) { id=Integer.parseInt(rs.getString(1)); str=rs.getString(5); st.executeUpdate("update chat_message set flag=1 where id=" + id ); System.out.println(str); return(str); } }catch(Exception e){} return(str); } //-------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------// public String getValue(String sid,String rid) { int id=0; str1=""; try{ ResultSet rs=st.executeQuery("select id,msg from chat_message where type='P' and flag=0 and sid='" + sid + "' and rid='"+rid+"'"); while(rs.next()) { id=Integer.parseInt(rs.getString(1)); str1=rs.getString(2); } st.executeUpdate("update chat_message set flag=1 where id=" + id ); }catch(Exception e){} return(str1); } //-------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------// public String setValue(String val,String sid) { String mk1; try{ ResultSet rs=st.executeQuery("select * from chat_users where id not like '"+sid+"'"); Statement mst=cn.createStatement(); while(rs.next()) { count++; mst.executeUpdate("insert into chat_message values("+count + ",'"+sid+"','"+rs.getString(1)+"','G','"+val+"',0)"); } }catch(Exception e){System.out.println("Error during writing Data setValue() : " + e);} return(val); } //-------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------// public String setValue(String val,String sid,String rid) { count++;

try{ st.executeUpdate("insert into chat_message values("+count + ",'"+sid+"','"+rid+"','P','"+val+"',0)"); }catch(Exception e){} return(val); } //-------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------// public int setName(String nam) { int flag=0; try{ ResultSet rs=st.executeQuery("select * from chat_users where id like'" + nam + "'"); while(rs.next()) { flag=1; } if(flag==0) { st.executeUpdate("insert into chat_users values('"+nam+"')"); str=nam + " is Login " + "\n"; if(name==null) name=nam+":"; else name=name+nam+":"; } }catch(Exception e){} // } //-------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------// public String getName() { return(name); } //-------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------// public void removeName(String nam) { try{ st.executeUpdate("delete from chat_users where id like '"+nam+"'"); System.out.println("USER " + nam + " is log out"); ResultSet rs=st.executeQuery("select * from chat_users"); name=""; while(rs.next()) { name=name+rs.getString(1)+":"; } str=nam + " Log out \n"; System.out.println("After removing name : "+name); }catch(Exception e){System.out.println("Error during removing name : " +name +" : " + e);name="";} System.out.println("After Inserting The name : "+ name); return(flag);

} //-------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------// public void setPersonal(String sid,String rid) { count1++; try{ st.executeUpdate("insert into chat_personal values("+count1+",'"+sid + "','"+rid+"',0)"); }catch(Exception e){System.out.println("Error at oracle : " + e);} } //-------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------// public String getPersonal(String rid) { String str=""; int id=0; try{ ResultSet rs=st.executeQuery("select * from chat_personal where flag=0 and rid='"+rid+"'"); while(rs.next()) { id=Integer.parseInt(rs.getString(1)); str=rs.getString(2); } st.executeUpdate("update chat_personal set flag=1 where id=" + id ); }catch(Exception e){} return(str); } //-------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------// protected void finalize()throws Exception { st.close(); cn.close(); } }

ChatServer.java

import java.rmi.*; class ChatServer { public static void main(String [] args) { try { ChatImp ct=new ChatImp(); Naming.rebind("bansal",ct); System.out.println("Server Started Successfully ..."); } catch(Exception e) { System.out.println("Error: to start Server \n " + e ); } } }

ChatClient.java
import java.rmi.*;

import java.awt.*; import java.awt.event.*; import java.applet.*; import javax.swing.*; /* <APPLET code=ChatClient.class width=500 height=280></APPLET>*/ class Login extends JFrame implements ActionListener { JTextField txtName; JButton cmdOK,cmdCancel; JLabel l1; Login() { Container cp = getContentPane(); cp.setLayout(null); ImageIcon ii=new ImageIcon("enter.gif"); JLabel l2=new JLabel(ii); txtName=new JTextField(); l1=new JLabel("Login Name : "); cmdOK=new JButton("OK"); cmdCancel=new JButton("Cancel"); l2.setBounds(10,35,40,20); l1.setBounds(10,10,150,20); txtName.setBounds(55,35,135,20); cmdOK.setBounds(15,65,75,20); cmdCancel.setBounds(115,65,75,20); cp.add(l2);cp.add(l1);cp.add(txtName);cp.add(cmdOK);cp.add(cmdCancel); cmdOK.addActionListener(this); cmdCancel.addActionListener(this); txtName.addActionListener(this); } public void actionPerformed(ActionEvent e1) { if(e1.getSource()==cmdOK || e1.getSource()==txtName) { final String str=txtName.getText(); if(str.length()>0) { try{ int mk; final ChatMain ct1=(ChatMain)Naming.lookup("rmi://localhost/bansal"); mk=ct1.setName(str); if(mk==1) { txtName.setText("This ID is alrady exist. Give Another ID"); return; } this.setVisible(false); Chat c1=new Chat(str); c1.setTitle("Chit-Chat : " + str); c1.setResizable(false); c1.setSize(1000,420); c1.setVisible(true); c1.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e1){try{ct1.removeName(str);}catch(Exception abc){}System.exit(0);}});

System.out.println("ChatClient: ready ..."); }catch(Exception e){System.out.println("Error :" + e);} } } else System.exit(0); } } public class ChatClient { public static void main(String []args) { Login l1=new Login(); l1.setTitle("Chit-Chat"); l1.setSize(200,120); l1.setLocation(400,200); l1.setState(Frame.NORMAL); l1.setResizable(false); l1.setVisible(true); l1.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e1) {System.exit(0);}}); System.out.println("ChatClient: Connected to Server Successfully ...") ; System.out.println("ChatClient: Starting the services ..."); } } class Chat extends JFrame implements ActionListener,Runnable,MouseListener { JTextField msgText; JTextArea mainText; JScrollPane jSP,jSPl; JButton sendBut; JList lstName; ChatMain ct; Thread th; String st1,st; String sName,uName; String users[]=new String[20]; int nou; Chat(String sN) { Container cp = getContentPane(); cp.setLayout(null); sName=sN; st1=""; ImageIcon ii=new ImageIcon("mk.jpg"); JLabel l2=new JLabel(ii); JLabel l3=new JLabel("Users :"); mainText=new JTextArea("Welcome to Chit-Chat ",390,250); jSP = new JScrollPane(); jSP.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jSP.setViewportView(mainText); lstName=new JList();

jSPl=new JScrollPane(); jSPl.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jSPl.setViewportView(lstName); msgText=new JTextField(""); sendBut=new JButton("Send"); nou=1; //////////////////////////////////// jSP.setBounds(225,5,620,335); l2.setBounds(1,1,220,390); l3.setBounds(850,5,100,20); jSPl.setBounds(850,25,140,315); msgText.setBounds(225,345,680,40); sendBut.setBounds(910,345,80,40); cp.add(l2);cp.add(l3); cp.add(jSP); cp.add(msgText); cp.add(sendBut);cp.add(jSPl); sendBut.addActionListener(this); msgText.addActionListener(this); lstName.addMouseListener(this); /////////////////////////////// try{ ct=(ChatMain)Naming.lookup("rmi://localhost/bansal"); }catch(Exception e){mainText.setText(mainText.getText()+"Error :Can't connect to Server");} th=new Thread(this,"mk"); th.start(); } public void run() { String nam,nam1[]; nam1=new String[50]; while(true) { try{ st=ct.getValue(sName); if(st.length()>0 && st.compareTo(st1)!=0) { st1=st; st=mainText.getText()+"\n"+st; mainText.setText(""); mainText.insert(st,0); } try{ nam=ct.getName(); lstName.removeAll(); int k=0; for(int i=0;i<nam.length();i++) { int j; j=nam.indexOf(":",i); if(nam.substring(i,j)!=null) nam1[k]=nam.substring(i,j); k++; i=j; }

String mk1[]=new String[k]; for(int i=0;i<k;i++) mk1[i]=nam1[i]; lstName.setListData(mk1); }catch(Exception e1){System.out.println("Error during inserting names :" +e1);} uName=ct.getPersonal(sName); if(uName.length()>0) { int fla=0,l; for(l=0;l<users.length && users[l]!=null;l++) { if(users[l].equals(uName)) fla=1; } if(fla==0) { users[l]=uName; final Personal p1=new Personal(sName,uName); p1.setTitle("ChatClient : " +uName); p1.setSize(315,210); p1.setResizable(false); p1.setVisible(true); p1.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e1){p1.setVisible(false);}}); } } Thread.sleep(500); }catch(Exception es){} } } public void mouseClicked(MouseEvent e) { int fla=0,l; if(sName.compareTo((String)lstName.getSelectedValue())==0) fla=1; for(l=0;l<users.length&&users[l]!=null;l++) { System.out.println(users[l]); if(users[l].compareTo((String)lstName.getSelectedValue())==0) fla=1; } if(fla==0) { users[l]=(String)lstName.getSelectedValue(); final Personal p1=new Personal(sName,(String)lstName.getSelectedValue()); try{ ct.setPersonal(sName,users[l]); }catch(Exception e7){} p1.setTitle("ChatClient : " +(String)lstName.getSelectedValue() ); p1.setSize(315,210); p1.setResizable(false); p1.setVisible(true); p1.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e1)

{ String tt=p1.getTitle(); tt=tt.substring(tt.indexOf(":")+2); System.out.println(tt); p1.setVisible(false); } }); } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void actionPerformed(ActionEvent ae) { try { if(ae.getSource()==sendBut || ae.getSource()==msgText) { if(msgText.getText().length()<=0) { msgText.setText("Enter some message here"); msgText.select(0,msgText.getText().length()); return; } st=ct.setValue(sName + " : " + msgText.getText(),sName); st1=st; msgText.select(0,st.length()); st=mainText.getText()+"\n"+st; mainText.setText(""); mainText.insert(st,0); } else if(ae.getSource()==lstName) { } } catch(Exception abc){} } /*void removeUsers(String uName) { String x_users[]=new String[20]; int l,m; for(l=0,m=0;l<users.length;l++) { if(uName.compareTo(users[l])==0) {} else

{ x_users[m]=users[l]; m++; } } users=new String[20]; for(l=0;l<x_users.length;l++) { users[l]=x_users[l]; } */

} }

class Personal extends JFrame implements ActionListener,Runnable { JTextField msgText; JTextArea mainText; JButton sendBut; JScrollPane jSP; ChatMain ct1; String sId,uId; Thread th; Personal(String Sid,String Uid) { Container cp = getContentPane(); cp.setLayout(null); sId=Sid;uId=Uid; msgText=new JTextField(); mainText=new JTextArea("Mohit Bansal's Chat Room",290,150); jSP = new JScrollPane(); jSP.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jSP.setViewportView(mainText); sendBut=new JButton("Send"); jSP.setBounds(5,5,300,150); msgText.setBounds(5,160,225,20); sendBut.setBounds(235,160,70,20); cp.add(jSP);cp.add(msgText); cp.add(sendBut); msgText.addActionListener(this); sendBut.addActionListener(this); try{ ct1=(ChatMain)Naming.lookup("rmi://localhost/bansal"); }catch(Exception e){mainText.setText(mainText.getText()+"Error :Can't connect to Server");} th=new Thread(this,"mk1"); th.start(); } public void run() { String st; try{ while(true) { st=ct1.getValue(uId,sId); if(st.length()>0) {

st=mainText.getText()+"\n"+st; mainText.setText(""); mainText.insert(st,0); } //mainText.insert(st + "\n",0); Thread.sleep(1000); } }catch(Exception es){} } public void actionPerformed(ActionEvent ae) { try{ if(msgText.getText().length()<=0) { msgText.setText("Enter some message here"); msgText.select(0,msgText.getText().length()); return; } String s=ct1.setValue(sId + " : " + msgText.getText(),sId,uId); msgText.select(0,s.length()); s=mainText.getText()+"\n"+s; mainText.setText(""); mainText.insert(s,0); //mainText.insert(s + "\n",0); }catch(Exception e){} } }

Part 7

Progress Table Conclusion Bibliography

Progress Table:
Project Name: Start Date: End Date: Group Members: CHAT SERVER 15 Feb, 2006 28 Apr, 2006 1. Mohit Kumar (Rollno 0402914049) 2. Tarun Kumar (Rollno 0402914107)

JOB NAME

START
15-2-2006 1-3-2006 4-3-2006 8-3-2006 10-3-2006 11-3-2006 12-3-2006 25-4-2006 -

END
29-2-2006 4-3-2006 8-3-2006 10-3-2006 11-3-2006 12-3-2006 25-4-2006 30-4-2006 -

REMARKS

1. for

Reading books project. 2. Collect information 3. Planning the Software 4. Requirement Analysis 5. Design Database 6. Design DFDs 7. Design ERDs 8. Development 9. Integration & Testing 10. Implementation

I studied books for this project which are given in Bibliography Collected information about the chat server within this period Completed the Planning for this software within this period We analyze all the necessary Requirements Designing all the Databases Designed DFDs for the flow of data Designed the ER Diagrams to show Relationship among entities Completed the coding for the Software. Completed all the testing about this Software -

CONCLUSION

o User Friendly ness is provided, as user has to just login and use the chat server. o A user can only login by giving a unique user name. o A no. of user can login at a time. o All the information in the database is deleted time to time, so the size of database will remain null most of the time. o There are two type of chat facility provided: - Group chat Personal Chat o Due to lake of time, there are no password mechanism. But soon I will implement it. o Its only a text based chat system, but soon I will implement voice chat also.

Bibliography

BOOK NAME
1. Java 2: The Complete Reference, Fifth Edition 2. 3. JAVA 2 :Black Book Programming With Java J2EE: The Complete Reference

AUTHOR
Herbert Schildt

Steven /holzner E. Balagurusamy Jim Keogh

4.

You might also like