Desktop Chat Application in Java
Desktop Chat Application in Java
Bachelor of Technology
In
Computer Science & Engineering
By
UJJAWAL SHARMA
To
Faculty Name,Designation,department
2017-2021
ACKNOWLEDGEMENT
I would like to thank Mr. MJS Dhillon (Director of INFOWIZ) for providing this
opportunity to take training on Core Java/Android technology under his guidance.
I would like to humbly and sincerely thank to Ms. Jenifa Chauhan, (Supervisor and
Department Manager) and Mr. Ankur (Trainer), INFOWIZ for their generous guidance,
valuable suggestions and encouragement given to me at different stages.
Last but not the least, I express my heartiest gratitude to Almighty god, my Parents for their
love and blessings to get such a wonderful opportunity
ABSTRACT
INFOWIZ is an 6 years young organization with ISO Certification which has been working
in the field of IT , Embedded System and has been providing its clients with exceptional
quality in Web Design, Web Development and SEO services. Our clients range from small,
medium to large scale Business houses & individuals. We also provide the off shore
companies of US, UK, France, Ireland, Canada and Australia with quality and timely Web
and SEO services.
INFOWIZ does not boast itself of being the best Development Company but enjoys reputable
position among top Web Development and Electronics companies because of our timely
delivery and quality work. Our skilled team of professionals make sure that the product is
developed as per the customer’s needs and also keeping the customer informed about the
development of his project from time to time. We do not only emphasize on formulating an
attractive solution to our clients but also believe in providing a workable solution. INFOWIZ
offers research based Search Engine Marketing products that help achieve greater insights to
customer’s online business. Our Research & Development arm offers SEO tools for SEM
professionals.
INTRODUCTION TO JAVA
Much of the syntax of Java is the same as C and C++. One major difference is
that Java does not have pointers. However, the biggest difference is that you must write
object oriented code in Java. Procedural pieces of code can only be embedded in objects. In
the following we assume that the reader has some familiarity with a programming language.
In particular, some familiarity with the syntax of C/C++ is useful.
In Java we distinguish between applications, which are programs that perform the
same functions as those written in other programming languages, and applets, which are
programs that can be embedded in a Web page and accessed over the Internet. Our initial
focus will be on writing applications. When a program is compiled, a byte code is produced
that can be read and executed by any platform that can run Java.
HISTORY
The team originally considered using C++, but it was rejected for several reasons.
Because they were developing an embedded system with limited resources, they decided that
C++ needed too much memory and that its complexity led to developer errors. The language's
lack of garbage collection meant that programmers had to manually manage system memory,
a challenging and error-prone task. The team was also troubled by the language's lack of
portable facilities for security, distributed programming, and threading. Finally, they wanted
a platform that could be easily ported to all types of devices.
Bill Joy had envisioned a new language combining Mesa and C. In a paper
called Further, he proposed to Sun that its engineers should produce an object-oriented
environment based on C++. Initially, Gosling attempted to modify and extend C++ (that he
referred to as "C++ ++ --") but soon abandoned that in favor of creating a new language,
which he called Oak, after the tree that stood just outside his office.
By the summer of 1992, they were able to demonstrate portions of the new
platform including the Green OS, the Oak language, the libraries, and the hardware. Their
first attempt, demonstrated on September 3, 1992, focused on building a personal digital
assistant (PDA) device named Star7 that had a graphical interface and a smart agent called
"Duke”to assist the user.
In November of that year, the Green Project was spun off to become firstperson,
a wholly owned subsidiary of Sun Microsystems, and the team relocated to Palo Alto,
California. The first person team was interested in building highly interactive devices, and
when Time Warner issued a request for proposal (RFP) for a set-top box, firstperson changed
their target and responded with a proposal for a set-top box platform. However, the cable
industry felt that their platform gave too much control to the user and firstperson lost their bid
to SGI. An additional deal with The 3DO Company for a set-top box also failed to
materialize. Unable to generate interest within the TV industry, the company was rolled back
into Sun.
BASICS OF JAVA
Overview Of Java
Define JRE
The Java Runtime Environment (JRE) is part of the Java Development Kit (JDK). It
contains set of libraries and tools for developing java application. The Java Runtime
Environment provides the minimum requirements for executing a Java application.
Define JVM
JVM is set of programs developed by sun Micro System and supplied as a part of jdk for
reading line by line of byte code and it converts into native understanding form of
operating system. Java language is one of the compiled and interpreted programming
language.
Garbage Collector
Garbage Collector is the system Java program which runs in the background along with
regular Java program to collect un-Referenced (unused) memory space for improving the
performance of our applications.
Define an API
Definition of JIT
JIT is the set of programs developed by SUN Micro System and added as a part of JVM, to
speed up the interpretation phase
Features Of JAVA
Features of a language are nothing but the set of services or facilities provided by the
language vendors to the industry programmers. Some important features are;
PATH VARIABLE
Path variable is set for providing path for all java tools like java, javac, javap, javah, jar,
appletviewer which are use in java programming. These all tools are available
in bin folders so we set path upto bin folders.
CLASSPATH VARIABLE
Classpath variable is set for providing path for predefined java classes which is used in
our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar.
The following sequence of steps represented in the diagram use compiling the java
program and executing the java programs.
Jvm, Jre, Jdk these all the backbone of java language. Each components have separate
works. Jdk and Jre physically exists but Jvm are abstract machine it means it not physically
exists.
JVM : JVM (Java Virtual Machine) is a software. It is a specification that provides runtime
environment in which java bytecode can be executed. It not physically exists.JVMs are not
same for all hardware and software, for example for window os JVM is different and for
Linux VJM is different. JVM, JRE and JDK are platform dependent because configuration
of each OS differs. But, Java is platform independent.
JRE : The Java Runtime Environment (JRE) is part of the Java Development Kit (JDK). It
contains set of libraries and tools for developing java application. The Java Runtime
Environment provides the minimum requirements for executing a Java application. It
physically exists. It contains set of libraries + other files that JVM uses at runtime.
JDK : The Java Development Kit (JDK) is primary components. It physically exists. It is
collection of programming tools and JRE, JVM.
Object is the physical as well as logical entity where as class is the only logical
entity.Class: Class is a blue print which is containing only list of variables and method and
no memory is allocated for them. A class is a group of objects that has common properties.
Data Member
Method
Constructor
Block
Class and Interface
Object: Object is a instance of class, object has state and behaviors.An Object in java has
three characteristics:
State
Behavior
Identity
State: Represents data (value) of an object.
Behavior: Represents the behavior (functionality) of an object such as deposit, withdraw
etc.
Identity: Object identity is typically implemented via a unique ID. The value of the ID is
not visible to the external user. But,it is used internally by the JVM to identify each object
uniquely.
Data Types
Datatype is a spacial keyword used to allocate sufficient memory space for the data, in
other words Data type is used for representing the data in main memory (RAM) of the
computer.
In general every programming language is containing three categories of data types. They
are
byte 0 1 byte
short 0 2 byte
int 0 4 byte
long 0L 8 byte
Variable is an identifier which holds data or another one variable is an identifier whose
value can be changed at the execution time of program. Variable is an identifier which can
be used to identify input data in a program.
Operator is a special symbol that tells the compiler to perform specific mathematical or
logical Operation. Java supports following lists of operators.
Arithmetic Operators
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Ternary or Conditional Operators
PROGRAMMING CONCEPTS
Structure of a java program is the standard format released by Language developer to the
Industry programmer. Sun Micro System has prescribed the following structure for the java
programmers for developing java application.
Main( ) Method
main() method is starting execution block of a java program or any java program start their
execution from main method. If any class contain main() method known as main class.
Looping Statement
for loop
While loop
do-while
Wrapper Classes
For each and every fundamental data type there exist a pre-defined class, Such predefined
class is known as wrapper class. The purpose of wrapper class is to convert numeric string
data into numerical or fundamental data.
Access modifiers:
Access modifiers are those which are applied before data members or methods of a class.
These are used to where to access and where not to access the data members or methods. In
java programming we have four access modifiers they are
JAVA USEFUL KEYWORDS
Final keyword
This keyword
this is a reference variable that refers to the current object. It is a keyword in java language
represents current class object
"this" keyword can be use in two ways.
this . (this dot)
this() (this off)
Super keyword
Super keyword in java is a reference variable that is used to refer parent class object. Super is
an implicit keyword create by JVM and supply each and every java program for performing
important role in three places.
At variable level
At method level
At constructor level
Synchronized Keyword
Synchronized Keyword is used for when we want to allow only one thread at a time then use
Synchronized modifier. If a method or block declared as a Synchronized then at a time only
one thread is allowed to operate on the given object.
Abstract Classes
We know that every java program must start with a concept of class that is without classes
concept there is no java program perfect.In java programming we have two types of classes
they are
1. Concrete class
2. Abstract class
Types of constructors
Based on creating objects in Java constructor are classified in two types. They are
Static block is a set of statements, which will be executed by the JVM before execution of
main method. At the time of class loading if we want to perform any activity we have to
define that activity inside static block because static block execute at the time of class
loading.
In a class we can take any number of static block but all these static block will be execute
from top to bottom.
Relationship in Java
Type of relationship always makes to understand how to reuse the feature from one class to
another class. In java programming we have two types of relationship they are.
Is-A Relationship
Has-A Relationship
Inheritance
The process of obtaining the data members and methods from one class to another class is
known as inheritance. It is one of the fundamental features of object-oriented
programming.
A class that is declared with abstract keyword, is known as abstract class. An abstract
class is one which is containing some defined method and some undefined method. In java
programming undefined methods are known as un-Implemented or abstract method.The
process of obtaining the data members and methods from one class to another class is
known as inheritance. It is one of the fundamental features of object-oriented
programming.
Types of Inheritance
Single inheritance
Multiple inheritance
Hierarchical inheritance
Multilevel inheritance
Hybrid inheritance
Method Overloading
Whenever same method name is exiting multiple times in the same class with different
number of parameter or different order of parameters or different types of parameters is
known as method overloading.
Suppose we have to perform addition of given number but there can be any number of
arguments, if we write method such as a(int, int)for two arguments, b(int, int, int) for three
arguments then it is very difficult for you and other programmer to understand purpose or
behaviors of method they can not identify purpose of method. So we use method
overloading to easily figure out the program. For example above two methods we can write
sum(int, int) and sum(int, int, int) using method overloading concept.
Method Overriding
Whenever same method name is existing in both base class and derived class with same
types of parameters or same order of parameters is known as method Overriding.
Interface
Interface is similar to class which is collection of public static final variables (constants)
and abstract methods.The interface is a mechanism to achieve fully abstraction in java.
There can be only abstract methods in the interface. It is used to achieve fully abstraction
and multiple inheritance in Java.
If we do not know about any things about implementation just we have requirement
specification then we should be go for Interface
If we are talking about implementation but not completely (partially implemented) then we
should be go for abstract
Abstraction
Abstraction is the concept of exposing only the required essential characteristics and
behavior with respect to a context.
Hiding of data is known as data abstraction. In object oriented programming language
this is implemented automatically while writing the code in the form of class and object .
Abstraction shows only important things to the user and hides the internal details for
example when we ride a bike, we only know about how to ride bike but can not know
about how it work ? and also we do not know internal functionality of bike.
Encapsulation
Benefits of encapsulation
Polymorphism is not a programming concept but it is one of the principal of OOPs. For
many objects oriented programming language polymorphism principle is common but
whose implementations are varying from one objects oriented programming language to
another object oriented programming language.
JAVA ADVANCED
Package
Purpose of package
The purpose of package concept is to provide common classes and interfaces for any
program separately. In other words if we want to develop any class or interface which is
common for most of the java programs than such common classes and interfaces must be
place in a package.
Exception Handling
The process of converting system error messages into user friendly error message is known
as Exception handling. This is one of the powerful feature of Java to handle run time error
and maintain normal flow of java application.
An Exception is an event, which occurs during the execution of a program, that disrupts
the normal flow of the program's Instructions.
Type of Exception
Checked Exception
Un-Checked Exception
Multithreading
1. New State
2. Ready State
3. Running State
4. Waiting State
5. Halted or dead State
String
String is a sequence of characters enclosed within double quotes (" ") is known as String.
Example: "Java Programming".
In java programming to store the character data we have a fundamental datatype
called char. Similarly to store the string data and to perform various operation on String
data, we have three predefined classes they are:
String
StringBuffer
StringBuilder
Collection
Collections in java is a framework that provides an architecture to store and manipulate the
group of objects.All the operations that you perform on a data such as searching, sorting,
insertion, manipulation, deletion etc. can be performed by Java Collections.Java Collection
simply means a single unit of objects. Java Collection framework provides many interfaces
(Set, List, Queue, Deque etc.) and classes (ArrayList, Vector, LinkedList, PriorityQueue,
HashSet, LinkedHashSet, TreeSet etc).