This report details the work done towards the project Chat Server. This particular project is a solution developed to communicate between the users across worldwide through Internet.
The concept of sending letters and telegraphs has been reduced due to the new era of Internet Mailing. One such facility is being provided by the Chat Server. A message or an information can be sent via many medias, such as it can be telephonic, telegrams, fax etc to the recipient. Each such information requires a high level of security. To maintain such security and smooth completion of any communication it requires more time and human effort in manual systems.
Chat Server automates all the aspects stated above related to a communication in a highly secure environment. This project has been developed to receive instant and urgent messages And to provide total user satisfaction.
The entire process has been automated using JAVA technology and SQL SERVER to smoothen the flow of information in a highly secure environment across the network. The solution has been deployed, tested and validated thoroughly. While designing the system, care has been taken in efficiency, maintenance and reusability of the software for the present and future changes in the system.
INTRODUCTION TO JAVA
Ø Features :-
The java programming language was designed to have following features:
· High performance
Ø Simple :-
Java was designed to be easy for the professional programmer to learn and use effectively. Assuming that you have some programming experience, you will not find Java hard to master. If you already understand the basic concepts of object-oriented programming, learning Java will be even easier. Best of all, if you are an experienced C++ programmer, moving to Java will require very little effort. Because Java inherits the C/C++ syntax and many of the object-oriented features of C++, most programmers have little trouble learning Java. Also, some of the more confusing concepts from C++ are either left out of Java or implemented in a cleaner, more approachable manner. Beyond its similarities with C/C++, Java has another attribute that makes it easy to learn: it makes an effort not to have surprising features. In Java, there are a small number of clearly defined ways to accomplish a given task.
Ø Secured :-
Although influenced by its predecessors, Java was not designed to be source-code compatible with any other language. This allowed the Java team the freedom to design with a blank slate. One outcome of this was a clean, usable, pragmatic approach to objects. Borrowing liberally from many seminal object-software environments of the last few decades, Java manages to strike a balance between the purist’s “everything is an object” paradigm and the pragmatist’s “stay out of my way” model. The object model in Java is simple and easy to extend, while simple types, such as integers, are kept as high-performance nonobjects.
Ø A Simple Java Program:-
A Java program can be written in many ways. This book introduces Java applications, applets and servlets . Applications are standalone programs that can be executed from any computer with a JVM. Applets are special kinds of Java programs that run from a CHAT SERVER .Servlets are special kinds of Java programs that run from a Web server to generate dynamic Web contents. Let us begin with a simple Java program that displays the message "Welcome to Java!" on the console. The program is shown.
Every Java program must have at least one class. A class is a construct that defines data and methods. Each class has a name. By convention, class names start with an uppercase letter. In this example, the class name is Welcome.
In order to run a class, the class must contain a method named main. The JVM executes the program by invoking the main method.
A method is a construct that contains statements. The main method in this program contains the System.out.println statement. This statement prints a message "Welcome to Java!" to the console.
Ø Creating, Compiling and Executing a Java Program :-
You have to create your program and compile it before it can be executed. This process is repetitive, If your program has compilation errors, you have to fix them by modifying the program, then recompile it. If your program has runtime errors or does not produce the correct result, you have to modify the program, recompile it, and execute it again.
Before compiling the java program on a Windows PC, you have to first set the CLASSPATH environment variable equals to the bin directory of the JDK(Java Development Kit) installation folder where Javac.exe and java.exe are present. You must first install and configure JDK before compiling and running programs. If you have trouble compiling and running programs, This also explains how to use basic DOS commands and how to use Windows NotePad and WordPad to create and edit files.
Key Features of Java used in the Project:-
The AWT stands for Abstract Window Toolkit. It is well-thought-out and very portable Windowing library. It is a standard part of the java environment and provides all the basic functionality one would expect to use in modern window system. It contain all the classes to write the program that interface between user and different windowing toolkits. We can use AWT to create user interfaces like Buttons, Checkboxes, Radio buttons, Menus etc.
To create any AWT application we have to use the following AWT Api’s:-
· Java.awt – It provides classes and interfaces to construct user interfaces, graphic contexts, images and obtaining information about the graphic environment.
· Java.awt.event- It provides interfaces and classes for dealing with different types of events fired by AWT components, For Example :-Button Pressed Event, Mouse Event, KeyBoard Event.
Swing is a successor to AWT package. The most significant problem with AWT is that the GUI developed in AWT is platform specific. It means it will not display its content the same way on different Operating Systems. But introduction of swings solved this problem. This is because swing uses its own mechanism to draw Components.
· Lightweight- It uses less resources than AWT components
· Increased Functionality- There are a number of components and functions that were not available with AWT that are now available with swings.
· Consistent look- Swing provides same look and feel on every operating system.
Ø Window Fundamentals :-
The SWINGS defines windows according to a class hierarchy that adds functionality and specificity with each level. The two most common windows are those derived from Panel, which is used by applets, and those derived from Frame, which creates a standard window. Much of the functionality of these windows is derived from their parent classes. Thus, a description of the class hierarchies relating to these two classes is fundamental to their understanding. Figure 21-1 shows the class hierarchy for Panel and Frame. Let’s look at each of these classes now.
Ø Component :-
At the top of the AWT hierarchy is the Component class. Component is an abstract class that encapsulates all of the attributes of a visual component. All user interface elements that are displayed on the screen and that interact with the user are subclasses of Component. It defines over a hundred public methods that are responsible for managing events, such as mouse and keyboard input, positioning and sizing the window, and repainting. (You already used many of these methods when you created applets in Chapters 19 and 20.) A Component object is responsible for remembering the current foreground and background colors and the currently selected text font.
Ø Panel :-
The Panel class is a concrete subclass of Container. It doesn’t add any new methods; it simply implements Container. A Panel may be thought of as a recursively nestable, concrete screen component. Panel is the superclass for Applet. When screen output is directed to an applet, it is drawn on the surface of a Panel object. In essence, a Panel is a window that does not contain a title bar, menu bar, or border. This is why you don’t see these items when an applet is run inside a browser. When you run an applet using an applet viewer, the applet viewer provides the title and border. Other components can be added to a Panel object by its add( ) method (inherited from Container). Once these components have been added, you can position and resize them manually using the setLocation( ), setSize( ), or setBounds( ) methods defined by Component.
Ø Window :-
The Window class creates a top-level window. A top-level window is not contained within any other object; it sits directly on the desktop. Generally, you won’t create Window objects directly. Instead, you will use a subclass of Window called Frame, described next.
This window demonstrate the File menu in the text editor. It has following options
· New- use to create a new text document.
· Open- use to open a text document.
· Save- use to save the existing document.
· Save As...- use to save the file to desired locaton.
· Exit- use to exit the Text Editor.
Ø Menu Bars and Menus:-
A top-level window can have a menu bar associated with it. A menu bar displays a list of top-level menu choices. Each choice is associated with a drop-down menu. This concept is implemented in Java by the following classes: MenuBar, Menu, and MenuItem. In general, a menu bar contains one or more Menu objects. Each Menu object contains a list of MenuItem objects.
Each MenuItem object represents something that can be selected by the user. Since Menu is a subclass of MenuItem, a hierarchy of nested submenus can be created. It is also possible to include checkable menu items. These are menu options of type CheckboxMenuItem and will have a check mark next to them when they are selected.To create a menu bar, first create an instance of MenuBar. This class only defines the default constructor. Next, create instances of Menu that will define the selections displayed on the bar. Following are the constructors for Menu:
Menu(String optionName, boolean removable)
Here, optionName specifies the name of the menu selection. If removable is true, the pop-up menu can be removed and allowed to float free. Otherwise, it will remain attached to the menu bar. (Removable menus are implementation-dependent.) The first form creates an empty menu.
Individual menu items are of type MenuItem. It defines these constructors:
MenuItem(String itemName, MenuShortcut keyAccel)
Here, itemName is the name shown in the menu, and keyAccel is the menu shortcut for this item. You can disable or enable a menu item by using the setEnabled( ) method. Its form
is shown here:
void setEnabled(boolean enabledFlag)
If the argument enabledFlag is true, the menu item is enabled. If false, the menu item is disabled.
The font menu contains different fonts that can be used int the text editors for editing purposes. Fonts that are present in the menubar are Serif, SansSerif, curier. Some other options that can change the font style are Bold and Italic options.
Ø Checkbox Menu Item :-
You can create a checkable menu item by using a subclass of MenuItem called CheckboxMenuItem. It has these constructors:
CheckboxMenuItem(String itemName, boolean on)
Here, itemName is the name shown in the menu. Checkable items operate as toggles. Each time one is selected, its state changes. In the first two forms, the checkable entry is unchecked. In the third form, if on is true, the checkable entry is initially checked. Otherwise, it is cleared. You can obtain the status of a checkable item by calling getState( ). You can set it to a known state by using setState( ). These methods are shown here:
boolean getState( )
void setState(boolean checked)
If the item is checked, getState( ) returns true. Otherwise, it returns false. To check an item, pass true to setState( ). To clear an item, pass false. Once you have created a menu item, you must add the item to a Menu object by using add( ), which has the following general form:
MenuItem add(MenuItem item) Here, item is the item being added. Items are added to a menu in the order in which the calls to add( ) take place. The item is returned. Once you have added all items to a Menu object, you can add that object to the menu bar by using this version of add( ) defined by MenuBar:
Menu add(Menu menu)
Here, menu is the menu being added. The menu is returned.
Menus only generate events when an item of type MenuItem or CheckboxMenuItem is selected. They do not generate events when a menu bar is accessed to display a drop-down menu, for example. Each time a menu item is selected, an ActionEvent object is generated. Each time a check box menu item is checked or unchecked, an ItemEvent object is generated. Thus, you must implement the ActionListener and ItemListener interfaces in order to handle these menu events. The getItem( ) method of ItemEvent returns a reference to the item that generated this event. The general form of this method is shown here:
Thus PAGE appear in the program when a user tries to press the GO button. Our program uses JEditorPane. JEditorPane is a java swings component that uses HTML language and render it to produce web content. JEditorPane uses setPage method to set the url of a webpage. This is given to JFditorpane’s setPage method. In this way webpage is rendered.
In my minor project development of WeBrowser, i have learned almost all the basic and Advance features of Core Java Programming.
Basic Features of Core Java that i have learned during training period:-
· Introduction to Java
· Data Types, Variables in Java
· Control Statements
· Classes and Objects
· Methods etc.
Advance features of Core Java i have learned during training period
· Packages and Interfaces
· Exception Handling
· Multithreaded Programming
· AWT, Swings and Applets
· Advance Console Programming
· Event handling
Java Database Connectivity