Chat Messanger
-
Upload
dipti-singh -
Category
Documents
-
view
226 -
download
0
Transcript of Chat Messanger
-
8/3/2019 Chat Messanger
1/23
CHAT MESSANGER
//codingimport java.net.*;
import java.io.*;
import java.util.*;
import java.awt.*;
class chatClient extends Frame implements Runnable
{
Socket soc;
TextField tf;
TextArea ta;
Button btnSend,btnClose;
String sendTo;
String LoginName;
Thread t=null;
DataOutputStream dout;
DataInputStream din;
chatClient(String LoginName,String chatwith) throws Exception{
super(LoginName);
this.LoginName=LoginName;
sendTo=chatwith;
tf=new TextField(50);
ta=new TextArea(50,50);
btnSend=new Button("Send");
btnClose=new Button("Close");soc=new Socket("127.0.0.1",5217);
din=new DataInputStream(soc.getInputStream());
dout=new DataOutputStream(soc.getOutputStream());
dout.writeUTF(LoginName);
-
8/3/2019 Chat Messanger
2/23
t=new Thread(this);
t.start();
}void setup()
{
setSize(600,400);
setLayout(new GridLayout(2,1));
add(ta);
Panel p=new Panel();
p.add(tf);
p.add(btnSend);
p.add(btnClose);
add(p);
show();
}
public boolean action(Event e,Object o){
if(e.arg.equals("Send"))
{
try
{
dout.writeUTF(sendTo + " " + "DATA" + " " +
tf.getText().toString());
ta.append("\n" + LoginName + " Says:" +
tf.getText().toString());tf.setText("");
}
catch(Exception ex)
{
}
-
8/3/2019 Chat Messanger
3/23
}
else if(e.arg.equals("Close"))
{
try
{dout.writeUTF(LoginName + " LOGOUT");
System.exit(1);
}
catch(Exception ex)
{
}
}
return super.action(e,o);
}
public static void main(String args[]) throws Exception
{
chatClient Client1=new chatClient(args[0],args[1]);
Client1.setup();}
public void run()
{
while(true)
{
try
{
ta.append( "\n" + sendTo + " Says :" + din.readUTF());
}
catch(Exception ex)
{
ex.printStackTrace();
}
-
8/3/2019 Chat Messanger
4/23
}
}
}
-
8/3/2019 Chat Messanger
5/23
//Chat Server
import java.net.*;
import java.util.*;
import java.io.*;
class chatServer
{
static Vector ClientSockets;
static Vector LoginNames;
chatServer() throws Exception
{ServerSocket soc=new ServerSocket(5217);
ClientSockets=new Vector();
LoginNames=new Vector();
while(true)
{
Socket CSoc=soc.accept();
AcceptClient obClient=new AcceptClient(CSoc);}
{
chatServer ob=new chatServer();
}
class AcceptClient extends Thread
{Socket ClientSocket;
DataInputStream din;
DataOutputStream dout;
AcceptClient (Socket CSoc) throws Exception
{
-
8/3/2019 Chat Messanger
6/23
ClientSocket=CSoc;
din=new DataInputStream(ClientSocket.getInputStream());
dout=new
DataOutputStream(ClientSocket.getOutputStream());
String LoginName=din.readUTF();
System.out.println("User Logged In :" + LoginName);
LoginNames.add(LoginName);
ClientSockets.add(ClientSocket);
start();
}
public void run()
{
while(true)
{
try
{ String msgFromClient=new String();
msgFromClient=din.readUTF();
StringTokenizer st=new
StringTokenizer(msgFromClient);
String Sendto=st.nextToken();
String MsgType=st.nextToken();
int iCount=0;
if(MsgType.equals("LOGOUT")){
for(iCount=0;iCount
-
8/3/2019 Chat Messanger
7/23
msg=msg+" " +st.nextToken();
}
for(iCount=0;iCount
-
8/3/2019 Chat Messanger
8/23
}
}
if(MsgType.equals("LOGOUT"))
{
break;}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
}
}
-
8/3/2019 Chat Messanger
9/23
WORLD COLLEGE OF TECHNOLOGY & MANAGEMENT
GURGAON-110058
Batch (2008-2012)
SUMMER TRAINING REPORT
ON
CHAT MESSANGER
Submitted in partial fulfillment of the requirements
for the award of the degree of
B.Tech
to
Maharishi Dayanand University, Rohtak
Guide: Submitted by:
Mr. RITESH Dipti Singh
19/I.T/08
-
8/3/2019 Chat Messanger
10/23
ACKNOWLEDGEMENT
Project work is essentially a learning process in which
apart from learning the subject itself, one also learns to
share ideas and work as a team. I am sure that
involvement in this project as well as the exposure I have
gained will prove to be stepping stone for other
opportunities that come in my way
I am thankful to my project guide Mr. ritesh who helped
in all ways to make this project a success.
Last but not least I am thankful to all those people who
have directly or indirectly contributed for the success of
this project.
Dipti singh
-
8/3/2019 Chat Messanger
11/23
INDEX
S.No. Topics Teacher
sSignatur
e1. About BHEL
Certificate2. About JAVA CORE
INTRODUCTION
FEATURES
BASIC JAVA PROGRAM
CONNECTIVITY
3. About Project
Introduction
Software used
Coding conclusion
-
8/3/2019 Chat Messanger
12/23
CORE JAVA
INTRODUCTION
In 1990, SunMicrosystembegan a project called
GREEN to develop software for consumer electronics.
It took 18months to develop the first working version.
This language initially called Oak, but was renamed toJava in 1995.
Java was conceived by James Gosling, Patrick Naughton,
Chris Warth, Ed Frank and Mike Sheridan. In 1991
Gosling began writing software in C++for embedding into
such items as toasters, VCRs etc. The embedded
software makes appliances more intelligent, typically by
adding Digital display or by using Artificial Intelligenceto better control mechanism. However, it soon become
apparent to Gosling that C++ was wrong tool for the job.
C++ is flexible enough to control embedded systems, but
it is susceptible to bugsthat can crash system. In
particular, C++ uses direct references to system
resources and requires programmer to keep track of how
these resources are managed, which is significant burdenon programmers. This burden of resource management is
a barrier to writing reliable, portable software and it is
serious problem for consumer electronics.
-
8/3/2019 Chat Messanger
13/23
FEATURES
Simple: A JAVA programmer need not know the
internal of java.
Object-oriented: Java defines data as object with
method that supports the objectoriented. Java is
purely objectoriented. Any codes you write, you have
to write in Class.
Distributed: Java programs can access data across theweb as easily as they access data from a local system.
Interpreted and Compiled: Java is both interpreted
and compiled. A java applet is written and compiled into
what is called bytecode. This byte code is binary and
platform independent. When this applet has to be
executed it is fetched to the local system where it isinterpreted by the browser. Only 80% is compiled and
20% interpreted when executed, this is because
security purpose. Java environment contains an
element called the linker. The linker checks the coming
data into your machine to make sure it does not contain
deliberately harmful files or files that could disrupt
the functioning your computer.
Architecture Natural: Java can work with a variety of
hardware and operating system. The only requirement
-
8/3/2019 Chat Messanger
14/23
is that the system should have java enabled Internet
browser.
Robust: Robust means reliable. A reliable language willallow you to write programs that dont crash when least
expected and will also be bug free.
Java is secure: A program traveling across the
Internet onto your machine is unseen by you and could
possibly be carrying a virus along with it. This is a
possibility in java program. But due to strong typechecking done by java on the users local machine, any
changes to the program are tagged as an error the
program will not executed.
Multithreaded: Ability of an applet to perform
multiple tasks at the same time. For e.g.; suppose you
are playing a game one thread displaying score, onegraphics. In single threaded applet only one task can
be performed at a given point of time.
Dynamic: A java program can consist of many modules
that are written by many programmers. These modules
may undergo many changes. Java makes
interconnection between modules at run time, which
easily avoids the problem caused by the changes of the
code used by your program java thus dynamic.
-
8/3/2019 Chat Messanger
15/23
BASIC JAVA PROGRAM
//Java Program
public class MyFirstProg{
public static void main(String args[])
{
System.out.println(This is first program);
}
}
Let us check it line by line:
Line 1: This line is called comment line, which will be
ignored by the compiler. They make program more
readable. The multiple line comment begins with /*and
ends with*/. A single line comment begins with a // and
ends at the end of the line.Line 2: In java everything should be in class which is
declared using the keyword class. public means your class
is available and accessible by any one.
MyFirstProg is the name of the class.
Line 4: The public keyword is an access specifier, which
controls the visibility and scope of class members.
The static keyword allows the main() method to be called,
without needing to create an instance of the class.
The void keyword tells the compiler that the main()
method does not return any value when it is executed.
-
8/3/2019 Chat Messanger
16/23
Main() is the entry point of your program i.e; programs
execution starts from here.
String is a type which stores character strings and args[]
is an array of type String.Line 6:System.out.println is used to print anything on the
console.
{} defines the scope of any method / class
; line terminator
-
8/3/2019 Chat Messanger
17/23
Saving File: Primary name of file must be same as the
name of the class and extension must be java.
Compilation: javac MyFirstProg.java
After compilation it creates .class file which is
bytecode format
-
8/3/2019 Chat Messanger
18/23
Execution: java MyFirstProg
-
8/3/2019 Chat Messanger
19/23
CONNECTIVITY
Connectivity is connecting FRONT END with BACK END.
Database Management:
A database is a collection of related information. A
DBMS is a software that provide us a mechanism to
retrieve, modify and add data to the database. Examples
are :MS-Access, MS SQL Server, Oracle, Sybase,
Informix and Ingress. Each DBMS/RDMS store the data
in their own format. MS Access stores in .mdb fileformat and MS SQL stores data in a .dat file format.
Using connectivity one can develop a application through
which user can interact with database like user can
add/retrieve/modify/delete data through that
application.
ODBC:
Is an abbreviation of Open Database Connectivity .It is a
interface used to interact with database from
programming language through its functions. It manages
this by inserting a middle layer called driver, between
the application and the DBMS. It translates queries of
application into commands that the DBMS understands.
For both the application and the DBMS must be
compliant.
JDBC:
-
8/3/2019 Chat Messanger
20/23
It provides a database programming for JAVA programs.
Since ODBC is an C interfacel thus JAVA program
cannot directly communicate with ODBC driver.
JavaSoft created the JDBC-ODBC Bridge driver thattranslate JDBC API to the ODBC API.
Steps for Database Access:
Import the java.sql package: import java.sql.*;
Load and register the driver:
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
Create a Connection object: Connectionc=DriverManager,getConnection(jdbc:odbc:DSN);
Create a Statement object: Statement
s=c.createStatement();
Execute the statement: ResultSet
r=s.executeQuery(select * from table);
Terminate connection: c.close();
-
8/3/2019 Chat Messanger
21/23
Introduction
NIIT is a leading Global Talent Development Corporation, building skilled
manpower pool for global industry requirements. The company which was set
up in 1981, to help the nascent IT industry overcome its human resource
challenges, has today grown to be amongst worlds leading talent
development companies offering learning solutions to Individuals,
Enterprises and Institutions across 40 countries.
NIITs training solutions in IT, Business Process Outsourcing, Banking,
Finance and Insurance, Executive Management Education, and Communication
and Professional Life Skills, touch five million learners every year. NIITs
expertise in learning content development, training delivery and education
process management make it the most preferred training partner,
worldwide.
Research-based Innovation, a key driver at NIIT, has enabled the
organisation to develop programs and curricula that use cutting-edge
instructional design methodologies and training delivery. NIITs Individual
Learning Business offerings include industry-endorsed programs forstudents seeking careers in IT New Age GNIIT(Indias First Cloud
Campus), Edgeineers and Global Net Plus for IT professionals.
NIIT has provided computer-based learning to over 15,000 government and
private schools. The futuristic NIITNGuru range for schools is a holistic
education package that comprises Interactive Classrooms (an embedded
http://niit.com/aboutniit/Pages/Overview.aspxhttp://image.providesupport.com/image/absolut.gifhttp://niit.com/services/ITEducationforIndividuals/CareerCourses/Pages/CareerCourse.aspxhttp://niit.com/aboutniit/PublishingImages/Overview/corporate3.bmphttp://niit.com/aboutniit/Pages/Overview.aspxhttp://image.providesupport.com/image/absolut.gifhttp://niit.com/services/ITEducationforIndividuals/CareerCourses/Pages/CareerCourse.aspxhttp://niit.com/aboutniit/PublishingImages/Overview/corporate3.bmp -
8/3/2019 Chat Messanger
22/23
Teaching Learning Material, that uses elements of interactivity, automation
and web links library); Math lab (technology tools that enable school
students to learn and explore mathematical concepts); IT Wizard (equips
the students with core computer knowledge and IT skills); Quick School (an
Education Resource Planning solution for school management); and MobileScience Lab (the first of its kind portable computerized Science Laboratory
which enables students to correlate scientific concepts taught in the class
to real life).
To address the vast population of underserved, school-aged children, NIIT
launched the Hole-in-the-Wall education initiative. Its achievements in the
area of Minimally Invasive Education earned NIIT the coveted Digital
Opportunity Award, by the World Information Technology Services Alliance
(WITSA) in 2008.
For working professionals, NIIT Imperia, Centre for Advanced Learning,
offers Executive Management Education Programs in association with IIM
Ahmadabad, IIM Calcutta, IIM Lucknow, IMT Ghaziabad and IIFT Delhi.
NIIT Imperia also offers specialized courses in Finance in association with
KPMG and on Digital Marketing with Google India and Internet and Mobile
Association of India (IAMAI).
NIIT Institute of Finance Banking & Insurance (IFBI), formed by NIIT
with equity participation from ICICI Bank, offers programs for individuals
and corporates in Banking, Financial Services and Insurance.
NIIT Uniqua, Centre for Process Excellence, addresses the increasing
demand for skilled workers in the business and technology services industry
by providing training programs in relevant areas. This is a part of NIIT
Institute of Process Excellence, a NIIT-Genpact venture.
NIIT Careers@Campus, the companys Institutional Alliances Business for
colleges and Universities, delivers in-campus training through Synchronous
Learning Technology.
NIITs Corporate Learning Solutions, NIITs Corporate Learning Solutions,
offers integrated learning solutions (including strategic consulting, learning
design, content development, delivery, technology, assessment and learning
http://niit.com/sites/Edgeineershttp://niit.com/aboutniit/Pages/ManagementTeam.aspxhttp://niit.com/services/ITEducationforIndividuals/HWandNetworkingCourses/Pages/HWandNetworkingCourses.aspxhttp://niit.com/aboutniit/Pages/Overview.aspxhttp://niit.com/services/SolutionsforSchool/Pages/SolutionsforSchool.aspxhttp://niit.com/services/SolutionsforSchool/Pages/SolutionsforSchool.aspxhttp://niitv2prd:7777/services/SolutionsforSchool/Math%20Lab/Pages/Math%20Lab.aspxhttp://niitv2prd:7777/services/SolutionsforSchool/IT%20Education/Pages/ITEducation.aspxhttp://niitv2prd:7777/services/SolutionsforSchool/Quick%20School/Pages/QuickSchool.aspxhttp://niit.com/services/SolutionsforSchool/Pages/MobileScienceLab.aspxhttp://niit.com/services/SolutionForColleges/Pages/SolutionsforColleges.aspxhttp://niit.com/aboutniit/Pages/Overview.aspxhttp://niit.com/sites/Edgeineershttp://niit.com/aboutniit/Pages/ManagementTeam.aspxhttp://niit.com/services/ITEducationforIndividuals/HWandNetworkingCourses/Pages/HWandNetworkingCourses.aspxhttp://niit.com/aboutniit/Pages/Overview.aspxhttp://niit.com/services/SolutionsforSchool/Pages/SolutionsforSchool.aspxhttp://niit.com/services/SolutionsforSchool/Pages/SolutionsforSchool.aspxhttp://niitv2prd:7777/services/SolutionsforSchool/Math%20Lab/Pages/Math%20Lab.aspxhttp://niitv2prd:7777/services/SolutionsforSchool/IT%20Education/Pages/ITEducation.aspxhttp://niitv2prd:7777/services/SolutionsforSchool/Quick%20School/Pages/QuickSchool.aspxhttp://niit.com/services/SolutionsforSchool/Pages/MobileScienceLab.aspxhttp://niit.com/services/SolutionForColleges/Pages/SolutionsforColleges.aspxhttp://niit.com/aboutniit/Pages/Overview.aspx -
8/3/2019 Chat Messanger
23/23
management) to Fortune 500 companies, Universities, Technology companies,
Training corporations and Publishing houses.
NIIT delivers a tailored combination of catalog learning products,
technology and services through Element K offerings. These include: vLab:hands-on labs, instructor-led courseware, comprehensive e-reference
libraries, technical journals, and KnowledgeHub: hosted learning
management platform. This makes NIIT the first and the best choice for
comprehensive learning solutions, worldwide.
NIITs innovative HR practices have been felicitated by Aon Hewitt as
amongst Top 25 Best Employers in India- 2011; Indian Education Awards
2011 as Best Education Company to Work with; by Great Places to Work
Institute as amongst Top 25 Indias Best Companies to Work for and Firstin Training & Education Industry, 2011.
Ushering in a new model in higher education is the not-for-profit NIIT
University, established in 2009 with a vision of being the leading centre of
innovation and learning in emerging areas of the Knowledge Society. Nestled
in the foothills of Aravali, in Neemrana, Rajasthan, the picturesque 100
acres fully residential green campus has been developed as an institute of
excellence based on the four core principles of providing industry linked,
technology based, research driven, seamless education
http://niit.com/aboutniit/Pages/Overview.aspxhttp://niitv2prd:7777/services/solutionforcorporates/Pages/Corporate_Training.aspxhttp://niitv2prd:7777/services/solutionforcorporates/Pages/Corporate_Training.aspxhttp://niit.com/aboutniit/Pages/Overview.aspxhttp://niitv2prd:7777/services/solutionforcorporates/Pages/Corporate_Training.aspxhttp://niitv2prd:7777/services/solutionforcorporates/Pages/Corporate_Training.aspx