SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
SIX WEEKS TRAINING REPORT
(JUNE-JULY’17)
JAVA AND IT’S APPLICATIONS
Submitted by: Submitted to:
Aisha Siddiqui Mr. R.N.Katiyar
CSE (2K14) (Reader CSE-Department)
005
UNIVERSITY INSTITUTE OF ENGINEERING AND
TECHNOLOGY
ACKNOWLEDGEMENT
I acknowledge my gratitude and thanks to all the well
knowledgeable people for giving me opportunity to avail
all the best facilities available at Varags Institute through
which I gained knowledge thinking so as too just in the
environment suitable for harmonic adjustment. I m
grateful to all the persons involved in this for various help
rendered by them during my vocational training period .I
would also thank my teachers , my friend and my family
members for their constant encouragement.
AISHA SIDDIQUI
CONTENTS
* History
* Features
* JVM , JRE , JDK
* Variables and Data Types
* Operators
* Wrapper Class
* Classes and Constructor
* Java OOPs Concepts
* Package
* Exception Handling
* Multithreading
* Strings
* Inner Class
* Regular Expressions
* Generics
* Collections
* JAVA IO
* Serialization
* Socket Programming
* JDBC
*Projects Undertaken
1 :> Creating a LAN (Client-Server) connection via
TCP/IP using socket Programming in JAVA
2 :> serialization and Deserialization of objects using the
concept of serialization and deserialization in JAVA
* Bibliography
HISTORY
Java is a programming language and environment invented by James
Gosling and others in 1994. Java was originally named Oak and was
developed as a part of the Green project at the Sun Company. Java is an
object-oriented programming language with a built-in
application programming interface (API) that can handle graphics
and user interfaces and that can be used to create applications or
applets. Because of its rich set of API's, similar to Macintosh and
Windows, and its platform independence, Java can also be thought of
as a platform in itself. Java also has standard libraries for doing
mathematics. Currently, Java is used in internet programming,
mobile devices, games, e-business solutions etc.
Java Version History
There are many java versions that have been released.
Current stable release of Java is Java SE 8.
1.JDK Alpha and Beta (1995)
2.JDK 1.0 (23rd Jan, 1996)
3.JDK 1.1 (19th Feb, 1997)
4.J2SE 1.2 (8th Dec, 1998)
5.J2SE 1.3 (8th May, 2000)
6.J2SE 1.4 (6th Feb, 2002)
7.J2SE 5.0 (30th Sep, 2004)
8.Java SE 6 (11th Dec, 2006)
9.Java SE 7 (28th July, 2011)
10. Java SE 8 (18th March, 2014)
Features of Java
There is given many features of java. They are also
known as java buzzwords. The Java Features given below
are simple and easy to understand.
1.Simple
2.Object-Oriented
3.Portable
4.Platform independent
5.Secured
6.Robust
7.Architecture neutral
8.Dynamic
9.Interpreted
10. Distributed High Performance
11. Multithreaded
Difference between JDK, JRE and JVM
JVM
JVM (Java Virtual Machine) is an abstract machine. It is a
specification that provides runtime environment in which
java byte code can be executed .JVMs are available for
many hardware and software platforms. JVM, JRE and
JDK are platform dependent because configuration of
each OS differs. But, Java is platform independent. The
JVM performs following main tasks:
o Loads code
o Verifies code
o Executes code
o Provides runtime environment
JRE
JRE is an acronym for Java Runtime Environment. It is
used to provide runtime environment .It is the
implementation of JVM. It physically exists. It contains
set of libraries + other files that JVM uses at runtime.
JDK
JDK is an acronym for Java Development Kit. It physically
exists .It contains JRE + development tools.
Variables and Data Types in Java
Variable is a name of memory location. There are three
types of variables in java: local, instance and static.
There are two types of data types in java: primitive and
non-primitive.
Local Variable
A variable which is declared inside the method is called
local variable.
Instance Variable
A variable which is declared inside the class but outside
the method, is called instance variable . It is not
declared as static.
Static variable
A variable that is declared as static is called static
variable. It cannot be local.
Data Types in Java
Data types represent the different values to be stored in
the variable. In java, there are two types of data types:
o Primitive data types
o Non-primitive data types
o
Operators in java
Operator in java is a symbol that is used to perform
operations. For example: +, -, *, / etc.
There are many types of operators in java which are
given below:
o Unary Operator,
o Arithmetic Operator,
o shift Operator,
o Relational Operator,
o Bitwise Operator,
o Logical Operator,
o Ternary Operator and
o Assignment Operator.
Wrapper class in Java
Wrapper class in java provides the mechanism to convert
primitive into object and object into primitive. Since J2SE
5.0, auto boxing and unboxing feature converts primitive
into object and object into primitive automatically. The
automatic conversion of primitive into object is known as
auto boxing and vice-versa unboxing
Java classes blocks n constructors
Class in Java
A class is a group of objects which have common
properties. It is a template or blueprint from which
objects are created. It is a logical entity. It can't be
physical. A class in Java can contain:
o fields
o methods
o constructors
o blocks
o nested class and interface
Object in Java
An entity that has state and behavior is known as an
object e.g. chair, bike, marker, pen, table, car etc. It can
be physical or logical (tangible and intangible). The
example of intangible object is banking system.An object
has three characteristics:
o State : represents data (value) of an object.
o Behavior: represents the behavior (functionality) of
an object such as deposit, withdraw etc.
o 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.
Constructor in Java
Constructor in java is a special type of method that is
used to initialize the object. Java constructor is invoked
at the time of object creation. It constructs the values
i.e. provides data for the object that is why it is known as
constructor.
Types of java constructors
There are two types of constructors:
* Default constructor (no-arguments constructor)
* Parameterized constructor
Java OOPs Concepts
Object Oriented Programming is a paradigm that provides
many concepts such as inheritance, data
binding, polymorphism etc. Simula is considered as the
first object-oriented programming language. The
programming paradigm where everything is represented
as an object , is known as truly object-oriented
programming language.
OOPs (Object Oriented Programming
System)
Object means a real word entity such as pen, chair, table
etc. Object-Oriented Programming is a methodology or
paradigm to design a program using classes and objects.
It simplifies the software development and maintenance
by providing some concepts:
o Object
o Class
o Inheritance
o Polymorphism
o Abstraction
o Encapsulation
Object
Any entity that has state and behavior is known as an
object. For example: chair, pen, table, keyboard, bike
etc. It can be physical and logical.
Class
Collection of objects is called class. It is a logical entity.
Inheritance
When one object acquires all the properties and
behaviours of parent object i.e. known as inheritance. It
provides code reusability. It is used to achieve runtime
polymorphism.
Polymorphism
When one task is performed by different ways i.e. known
as polymorphism. For example: to convince the customer
differently, to draw something e.g. shape or rectangle
etc. In java, we use method overloading and method
overriding to achieve polymorphism. Another example
can be to speak something e.g. cat speaks meaw, dog
barks woof etc.
Abstraction
Hiding internal details and showing functionality is known
as abstraction. For example: phone call, we don't know
the internal processing. In java, we use abstract class
and interface to achieve abstraction.
Encapsulation
Binding (or wrapping) code and data together into a
single unit is known as encapsulation. For example:
capsule, it is wrapped with different medicines. A java
class is the example of encapsulation. Java bean is the
fully encapsulated class because all the data members
are private here.
Java advanced
Java Package
A java package is a group of similar types of classes,
interfaces and sub-packages. Package in java can be
categorized in two form, built-in package and user-
defined package. There are many built-in packages such
as java, lang, awt, javax, swing, net, io, util, sql etc.
Here, we will have the detailed learning of creating and
using user-defined packages.
Advantage of Java Package
1) Java package is used to categorize the classes and
interfaces so that they can be easily maintained.
2) Java package provides access protection.
3) Java package removes naming collision.
Exception Handling in Java
The exception handling in java is one of the
powerful mechanism to handle the runtime errors so that
normal flow of the application can be maintained In java,
exception is an event that disrupts the normal flow of the
program. It is an object which is thrown at runtime.
What is exception handling
Exception Handling is a mechanism to handle runtime
errors such as ClassNotFound, IO, SQL, Remote etc.
Advantage of Exception Handling
The core advantage of exception handling is to maintain
the normal flow of the application. Exception normally
disrupts the normal flow of the application that is why we
use exception handling.
Types of Exception
There are mainly two types of exceptions: checked and
unchecked where error is considered as unchecked
exception. The sun microsystem says there are three
types of exceptions:
1) Checked Exception
The classes that extend Throwable class except
RuntimeException and Error are known as checked
exceptions e.g.IOException, SQLException etc. Checked
exceptions are checked at compile-time.
2) Unchecked Exception
The classes that extend RuntimeException are known as
unchecked exceptions e.g. ArithmeticException,
NullPointerException, ArrayIndexOutOfBoundsException
etc. Unchecked exceptions are not checked at compile-
time rather they are checked at runtime.
3) Error
Error is irrecoverable e.g. OutOfMemoryError, VirtualMachineError, AssertionError etc.
Multithreading in Java
Multithreading in java is a process of executing multiple
threads simultaneously. Thread is basically a lightweight
sub-process, a smallest unit of processing.
Multiprocessing and multithreading, both are used to
achieve multitasking. But we use multithreading than
multiprocessing because threads share a common
memory area. They don't allocate separate memory area
so saves memory, and context-switching between the
threads takes less time than process. Java Multithreading
is mostly used in games, animation etc.
Advantages of Java Multithreading
1) It doesn't block the user because threads are
independent and you can perform multiple operations at
same time.
2) You can perform many operations together so it saves
time.
3) Threads are independent so it doesn't affect other
threads if exception occur in a single thread.
Java String
In java, string is basically an object that represents
sequence of char values. An array of characters works
same as java string. For example:
1.char[] ch={'j','a','v','a','t','p','o','i','n','t'};
2.String s=new String(ch);
is same as:
1.String s="javatpoint";
Java String class provides a lot of methods to perform
operations on string such as compare(), concat(),
equals(), split(), length(), replace(), compareTo(),
intern(), substring() etc.
The java.lang.String class
implements Serializable, Comparable and CharSequence i
nterfaces.
Java Inner Classes
Java inner class or nested class is a class which is
declared inside the class or interface. We use inner
classes to logically group classes and interfaces in one
place so that it can be more readable and maintainable.
Additionally, it can access all the members of outer class
including private data members and methods.
Java Regex
The Java Regex or Regular Expression is an API to define
pattern for searching or manipulating strings. It is widely
used to define constraint on strings such as password
and email validation. After learning java regex tutorial,
you will be able to test your own regular expressions by
the Java Regex Tester Tool. Java Regex API provides 1
interface and 3 classes in java.util.regex package.
java.util.regex package
It provides following classes and interface for regular
expressions. The Matcher and Pattern classes are widely
used in java regular expression.
1.MatchResult interface
2.Matcher class
3.Pattern class
4.PatternSyntaxException class
Generics in Java
The Java Generics programming is introduced in J2SE 5
to deal with type-safe objects. Before generics, we can
store any type of objects in collection i.e. non-generic.
Now generics, forces the java programmer to store
specific type of objects.
Advantage of Java Generics
There are mainly 3 advantages of generics. They are as
follows:
1) Type-safety : We can hold only a single type of objects
in generics. It doesn’t allow to store other objects.
2) Type casting is not required: There is no need to
typecast the object.
3) Compile-Time Checking: It is checked at compile time
so problem will not occur at runtime. The good
programming strategy says it is far better to handle the
problem at compile time than runtime.
Collections in Java
Collections in java are a framework that provides
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.).
Java I/O
Java I/O (Input and Output) is used to process the
input and produce the output. Java uses the concept of
stream to make I/O operation fast. The java.io package
contains all the classes required for input and output
operations. We can perform file handling in java by Java
I/O API.
Stream
A stream is a sequence of data .In Java a stream is
composed of bytes. It's called a stream because it is like
a stream of water that continues to flow. In java, 3
streams are created for us automatically. All these
streams are attached with console.
1) System.out: standard output stream
2) System.in: standard input stream
3) System.err: standard error stream
OutputStream
Java application uses an output stream to write data to a
destination, it may be a file, an array, peripheral device
or socket.
InputStream
Java application uses an input stream to read data from a
source, it may be a file, an array, peripheral device or
socket.
Serialization in java
Serialization in java is a mechanism of writing the state
of an object into a byte stream .It is mainly used in
Hibernate, RMI, JPA, EJB and JMS technologies .The
reverse operation of serialization is called deserialization.
Advantage of Java Serialization
It is mainly used to travel object's state on the network
(known as marshaling).
Deserialization in java
Deserialization is the process of reconstructing the object
from the serialized state.It is the reverse operation of
serialization.
Java Socket Programming
Java Socket programming is used for communication
between the applications running on different JRE. Java
Socket programming can be connection-oriented or
connection-less. Socket and ServerSocket classes are
used for connection-oriented socket programming and
DatagramSocket and DatagramPacket classes are used
for connection-less socket programming. The client in
socket programming must know two information:
1.IP Address of Server, and
2.Port number.
Socket class
A socket is simply an endpoint for communications
between the machines. The Socket class can be used to
create a socket.
Java JDBC
Java JDBC is a java API to connect and execute query
with the database. JDBC API uses jdbc drivers to connect
with the database.
Why use JDBC
Before JDBC, ODBC API was the database API to connect
and execute query with the database. But, ODBC API
uses ODBC driver which is written in C language (i.e.
platform dependent and unsecured). That is why Java
has defined its own API (JDBC API) that uses JDBC
drivers (written in Java language).
CREATING A LAN (CLIENT -SERVER)
CONNECTION VIA TCP/IP USING
SOCKET PROGRAMMING IN JAVA
Objective:
The server and client present on different machines can
have live chat until server says “stop” to terminate the
connection.
INTRODUCTION
In this project, I have described the steps to make a
connection in Java using Sockets. Let's start to
understand what a communication link is created via
TCP/IP. A communication link created via TCP/IP sockets
is a connection-oriented link and is reliable. This means
that the connection between the server and client
remains open throughout the duration of the dialogue
between the two and is only broken (under normal
circumstances) when one end of the dialogue formally
terminates the exchanges (like in our case when the
clients says “stop”).
FEATURES
* Network based application having two faces:
:> One for client
:> One for server
* It has two page source codes: one for server and one
for client.
* The machines are connected through a LAN cable.
* The machines have jre n jdk files installed on them to
run java code.
STEPS ON SERVER SIDE
* Establish a connection to the server.
* Create a ServerSocket object.
* Put the server into a waiting state.
* Set up input and output streams.
* Send and receive data.
JAVA CODE ON SERVER SIDE
import java.net.*;
import java.io.*;
class MyServer{
public static void main(String args [])throws Exception{
ServerSocket ss=new ServerSocket(3333);
Socket s=ss.accept();
DataInputStream din=new
DataInputStream(s.getInputStream());
DataOutputStream dout=new
DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
String str="",str2="";
while(!str.equals("stop")){
str=din.readUTF();
System.out.println("client says: "+str);
str2=br.readLine();
dout.writeUTF(str2);
dout.flush();
}
din.close();
s.close();
ss.close();
}}
STEPS ON CLIENT SIDE
* Establish a connection to the server.
* Set up input and output streams.
* Send and receive data.
* Close the connection.
JAVA CODE ON CLIENT SIDE
import java.net.*;
import java.io.*;
class MyClient{
public static void main(String args[])throws Exception{
Socket s=new Socket("localhost",3333);
DataInputStream din=new
DataInputStream(s.getInputStream());
DataOutputStream dout=new
DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
String str="",str2="";
while(!str.equals("stop")){
str=br.readLine();
dout.writeUTF(str);
dout.flush();
str2=din.readUTF();
System.out.println ("Server says: "+str2);
}
dout.close();
s.close();
}}
SCREENSHOTS SHOWING A GLIMPSE
OF HOW THE CHAT WORKS
* Bringing the client and server under the same network.
:// Control Panel>Network and Internet>Network and
Sharing Center>Ethernet
://Properties>Networking>Internet Protocol Version 6
(TCP/IPv4) >OK
:// Providing the IP Address
* Code on server is compiled and run.
* Code on client side is compiled and run.
* Chat on client side
* Chat on server side
*Server asks client to terminate the chat.
* Chat terminates when client says “stop”.
EXTENSION
This concept can be used for MULTIPLE CLIENT SERVER
CHAT too using the concept of threads along with the
ones used in the above project.
SERIALISATION AND
DESERIALISATION OF OBJECTS
USING THE CONCEPT OF
SERIALISATION AND
DESREALISATION IN JAVA
OBJECTIVE
In this, there is a class and one program is trying to
serialize it i.e. write it on a file and later some other
program wants to it read it from the fie i.e. deserialise it
and again get back to the same form. It’s kind of a mini
project showing this concept in java.
INTRODUCTION
Serialization in java is a mechanism of writing the state
of an object into a byte stream. Writing an object on file
is serialization and reconstructing it from file is
deserialization. The file that stores the object has
extension .ser in this case the file is address.ser . In this
implementation, the state of objects is printed in the
order the objects are created.
FEATURES
* The class that’s implementing the built in class
Serializable is Address.
* The class that’s storing objects on the file is
WriteObject.class.
* The class that’s reading objects from the file is
ReadObject.class.
CODE FOR CLASS Address
import java.io.Serializable;
public class Address implements Serializable{
private static final long serialVersionUID = 1L;
String street;
String country;
public void setStreet(String street)
{
this.street=street;
}
public void setCountry(String country)
{
this.country=country;
}
public String getStreet()
{
return this.street;
}
public String getCountry()
{
return this.country;
}
@Override
public String toString()
{
return new StringBuffer("Street :")
.append(this.street)
.append("country :")
.append(this.country).toString();
}
}
CODE FOR CLASS WriteObject
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
public class WriteObject{
public static void main (String args[])
{
Address address = new Address();
Address address2 = new Address();
address.setStreet("Delhi");
address.setCountry("india");
address2.setStreet("Del");
address2.setCountry("ina");
try
{
FileOutputStream fout = new
FileOutputStream("address.ser");
ObjectOutputStream oos = new
ObjectOutputStream(fout);
oos.writeObject(address);
oos.writeObject(address2);
oos.close();
System.out.println("done");
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
CODE FOR CLASS ReadObject
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
public class WriteObject{
public static void main (String args[])
{
Address address = new Address();
Address address2 = new Address();
address.setStreet("Delhi");
address.setCountry("india");
address2.setStreet("Del");
address2.setCountry("ina");
try
{
FileOutputStream fout = new
FileOutputStream("address.ser");
ObjectOutputStream oos = new
ObjectOutputStream(fout);
oos.writeObject(address);
oos.writeObject(address2);
oos.close();
System.out.println("done");
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
SCREENSHOTS SHOWING THE
OUTPUT
:// Class Address is run.
:// Code of WriteObject is run and compiled.
:// Code for ReadObject is run and compiled.
BIBLIOGRAPHY
BOOKS
>> The Complete Reference Java2 fifth edition
(By :- Herbert
Scheldt)
>> Java Book by Balaguruswamy
REFERENCES
>>www.tutorilspoint.com/java
>>www.allschoolstuff.com

Contenu connexe

Tendances

Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Languagejaimefrozr
 
Spring Boot Interview Questions | Edureka
Spring Boot Interview Questions | EdurekaSpring Boot Interview Questions | Edureka
Spring Boot Interview Questions | EdurekaEdureka!
 
Genesis and Overview of Java
Genesis and Overview of Java Genesis and Overview of Java
Genesis and Overview of Java Ravi_Kant_Sahu
 
Industrial Training Report on Java Technology.
Industrial Training Report on Java Technology.Industrial Training Report on Java Technology.
Industrial Training Report on Java Technology.Ritesh Kumar Bhanu
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java SlidesVinit Vyas
 
Core Java
Core JavaCore Java
Core JavaNA
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)Sujit Majety
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)arvind pandey
 
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...Edureka!
 

Tendances (20)

Java presentation
Java presentation Java presentation
Java presentation
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
Spring Boot Interview Questions | Edureka
Spring Boot Interview Questions | EdurekaSpring Boot Interview Questions | Edureka
Spring Boot Interview Questions | Edureka
 
Genesis and Overview of Java
Genesis and Overview of Java Genesis and Overview of Java
Genesis and Overview of Java
 
Industrial Training Report on Java Technology.
Industrial Training Report on Java Technology.Industrial Training Report on Java Technology.
Industrial Training Report on Java Technology.
 
Industrial Training report on java
Industrial  Training report on javaIndustrial  Training report on java
Industrial Training report on java
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java Slides
 
Java
JavaJava
Java
 
JDK,JRE,JVM
JDK,JRE,JVMJDK,JRE,JVM
JDK,JRE,JVM
 
Core Java
Core JavaCore Java
Core Java
 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Java basic
Java basicJava basic
Java basic
 
Java PPT
Java PPTJava PPT
Java PPT
 
React js
React jsReact js
React js
 
Core Java
Core JavaCore Java
Core Java
 
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
 
JAVA PPT Part-1 BY ADI.pdf
JAVA PPT Part-1 BY ADI.pdfJAVA PPT Part-1 BY ADI.pdf
JAVA PPT Part-1 BY ADI.pdf
 
Core java
Core javaCore java
Core java
 

Similaire à A seminar report on core java

Similaire à A seminar report on core java (20)

3. jvm
3. jvm3. jvm
3. jvm
 
Java
JavaJava
Java
 
Java basic
Java basicJava basic
Java basic
 
javaopps concepts
javaopps conceptsjavaopps concepts
javaopps concepts
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit Notes
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
1 .java basic
1 .java basic1 .java basic
1 .java basic
 
Cs8392 oops 5 units notes
Cs8392 oops 5 units notes Cs8392 oops 5 units notes
Cs8392 oops 5 units notes
 
java notes.pdf
java notes.pdfjava notes.pdf
java notes.pdf
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, Mysuru
 
Computer Programming 2
Computer Programming 2 Computer Programming 2
Computer Programming 2
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 
Java basic concept
Java basic conceptJava basic concept
Java basic concept
 
Qb it1301
Qb   it1301Qb   it1301
Qb it1301
 
DAY_1.1.pptx
DAY_1.1.pptxDAY_1.1.pptx
DAY_1.1.pptx
 
PROGRAMMING IN JAVA unit 1.pptx
PROGRAMMING IN JAVA unit 1.pptxPROGRAMMING IN JAVA unit 1.pptx
PROGRAMMING IN JAVA unit 1.pptx
 
Java interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council Pune
 
java slides
java slidesjava slides
java slides
 
Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 

Dernier

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 

Dernier (20)

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 

A seminar report on core java

  • 1. SIX WEEKS TRAINING REPORT (JUNE-JULY’17) JAVA AND IT’S APPLICATIONS Submitted by: Submitted to: Aisha Siddiqui Mr. R.N.Katiyar CSE (2K14) (Reader CSE-Department) 005 UNIVERSITY INSTITUTE OF ENGINEERING AND TECHNOLOGY
  • 2. ACKNOWLEDGEMENT I acknowledge my gratitude and thanks to all the well knowledgeable people for giving me opportunity to avail all the best facilities available at Varags Institute through which I gained knowledge thinking so as too just in the environment suitable for harmonic adjustment. I m grateful to all the persons involved in this for various help rendered by them during my vocational training period .I would also thank my teachers , my friend and my family members for their constant encouragement. AISHA SIDDIQUI
  • 3.
  • 4.
  • 5. CONTENTS * History * Features * JVM , JRE , JDK * Variables and Data Types * Operators * Wrapper Class * Classes and Constructor * Java OOPs Concepts * Package * Exception Handling * Multithreading * Strings * Inner Class * Regular Expressions * Generics * Collections * JAVA IO * Serialization * Socket Programming
  • 6. * JDBC *Projects Undertaken 1 :> Creating a LAN (Client-Server) connection via TCP/IP using socket Programming in JAVA 2 :> serialization and Deserialization of objects using the concept of serialization and deserialization in JAVA * Bibliography
  • 7. HISTORY Java is a programming language and environment invented by James Gosling and others in 1994. Java was originally named Oak and was developed as a part of the Green project at the Sun Company. Java is an object-oriented programming language with a built-in application programming interface (API) that can handle graphics and user interfaces and that can be used to create applications or applets. Because of its rich set of API's, similar to Macintosh and Windows, and its platform independence, Java can also be thought of as a platform in itself. Java also has standard libraries for doing mathematics. Currently, Java is used in internet programming, mobile devices, games, e-business solutions etc. Java Version History There are many java versions that have been released. Current stable release of Java is Java SE 8. 1.JDK Alpha and Beta (1995) 2.JDK 1.0 (23rd Jan, 1996) 3.JDK 1.1 (19th Feb, 1997) 4.J2SE 1.2 (8th Dec, 1998) 5.J2SE 1.3 (8th May, 2000) 6.J2SE 1.4 (6th Feb, 2002) 7.J2SE 5.0 (30th Sep, 2004) 8.Java SE 6 (11th Dec, 2006) 9.Java SE 7 (28th July, 2011)
  • 8. 10. Java SE 8 (18th March, 2014) Features of Java There is given many features of java. They are also known as java buzzwords. The Java Features given below are simple and easy to understand. 1.Simple 2.Object-Oriented 3.Portable 4.Platform independent 5.Secured 6.Robust 7.Architecture neutral 8.Dynamic 9.Interpreted 10. Distributed High Performance 11. Multithreaded Difference between JDK, JRE and JVM JVM JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java byte code can be executed .JVMs are available for many hardware and software platforms. JVM, JRE and JDK are platform dependent because configuration of
  • 9. each OS differs. But, Java is platform independent. The JVM performs following main tasks: o Loads code o Verifies code o Executes code o Provides runtime environment JRE JRE is an acronym for Java Runtime Environment. It is used to provide runtime environment .It is the implementation of JVM. It physically exists. It contains set of libraries + other files that JVM uses at runtime. JDK JDK is an acronym for Java Development Kit. It physically exists .It contains JRE + development tools. Variables and Data Types in Java Variable is a name of memory location. There are three types of variables in java: local, instance and static. There are two types of data types in java: primitive and non-primitive. Local Variable A variable which is declared inside the method is called local variable.
  • 10. Instance Variable A variable which is declared inside the class but outside the method, is called instance variable . It is not declared as static. Static variable A variable that is declared as static is called static variable. It cannot be local. Data Types in Java Data types represent the different values to be stored in the variable. In java, there are two types of data types: o Primitive data types o Non-primitive data types
  • 11. o Operators in java Operator in java is a symbol that is used to perform operations. For example: +, -, *, / etc. There are many types of operators in java which are given below: o Unary Operator, o Arithmetic Operator, o shift Operator, o Relational Operator, o Bitwise Operator,
  • 12. o Logical Operator, o Ternary Operator and o Assignment Operator. Wrapper class in Java Wrapper class in java provides the mechanism to convert primitive into object and object into primitive. Since J2SE 5.0, auto boxing and unboxing feature converts primitive into object and object into primitive automatically. The automatic conversion of primitive into object is known as auto boxing and vice-versa unboxing Java classes blocks n constructors Class in Java A class is a group of objects which have common properties. It is a template or blueprint from which objects are created. It is a logical entity. It can't be physical. A class in Java can contain: o fields o methods o constructors o blocks o nested class and interface Object in Java An entity that has state and behavior is known as an object e.g. chair, bike, marker, pen, table, car etc. It can
  • 13. be physical or logical (tangible and intangible). The example of intangible object is banking system.An object has three characteristics: o State : represents data (value) of an object. o Behavior: represents the behavior (functionality) of an object such as deposit, withdraw etc. o 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. Constructor in Java Constructor in java is a special type of method that is used to initialize the object. Java constructor is invoked at the time of object creation. It constructs the values i.e. provides data for the object that is why it is known as constructor. Types of java constructors There are two types of constructors: * Default constructor (no-arguments constructor) * Parameterized constructor Java OOPs Concepts Object Oriented Programming is a paradigm that provides many concepts such as inheritance, data binding, polymorphism etc. Simula is considered as the
  • 14. first object-oriented programming language. The programming paradigm where everything is represented as an object , is known as truly object-oriented programming language. OOPs (Object Oriented Programming System) Object means a real word entity such as pen, chair, table etc. Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance by providing some concepts: o Object o Class o Inheritance o Polymorphism o Abstraction o Encapsulation Object Any entity that has state and behavior is known as an object. For example: chair, pen, table, keyboard, bike etc. It can be physical and logical. Class Collection of objects is called class. It is a logical entity.
  • 15. Inheritance When one object acquires all the properties and behaviours of parent object i.e. known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism. Polymorphism When one task is performed by different ways i.e. known as polymorphism. For example: to convince the customer differently, to draw something e.g. shape or rectangle etc. In java, we use method overloading and method overriding to achieve polymorphism. Another example can be to speak something e.g. cat speaks meaw, dog barks woof etc. Abstraction Hiding internal details and showing functionality is known as abstraction. For example: phone call, we don't know the internal processing. In java, we use abstract class and interface to achieve abstraction. Encapsulation Binding (or wrapping) code and data together into a single unit is known as encapsulation. For example: capsule, it is wrapped with different medicines. A java class is the example of encapsulation. Java bean is the fully encapsulated class because all the data members are private here.
  • 16. Java advanced Java Package A java package is a group of similar types of classes, interfaces and sub-packages. Package in java can be categorized in two form, built-in package and user- defined package. There are many built-in packages such as java, lang, awt, javax, swing, net, io, util, sql etc. Here, we will have the detailed learning of creating and using user-defined packages. Advantage of Java Package 1) Java package is used to categorize the classes and interfaces so that they can be easily maintained. 2) Java package provides access protection. 3) Java package removes naming collision.
  • 17. Exception Handling in Java The exception handling in java is one of the powerful mechanism to handle the runtime errors so that normal flow of the application can be maintained In java, exception is an event that disrupts the normal flow of the program. It is an object which is thrown at runtime. What is exception handling Exception Handling is a mechanism to handle runtime errors such as ClassNotFound, IO, SQL, Remote etc. Advantage of Exception Handling
  • 18. The core advantage of exception handling is to maintain the normal flow of the application. Exception normally disrupts the normal flow of the application that is why we use exception handling. Types of Exception There are mainly two types of exceptions: checked and unchecked where error is considered as unchecked exception. The sun microsystem says there are three types of exceptions: 1) Checked Exception The classes that extend Throwable class except RuntimeException and Error are known as checked exceptions e.g.IOException, SQLException etc. Checked exceptions are checked at compile-time. 2) Unchecked Exception The classes that extend RuntimeException are known as unchecked exceptions e.g. ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException etc. Unchecked exceptions are not checked at compile- time rather they are checked at runtime. 3) Error Error is irrecoverable e.g. OutOfMemoryError, VirtualMachineError, AssertionError etc.
  • 19. Multithreading in Java Multithreading in java is a process of executing multiple threads simultaneously. Thread is basically a lightweight sub-process, a smallest unit of processing. Multiprocessing and multithreading, both are used to achieve multitasking. But we use multithreading than multiprocessing because threads share a common memory area. They don't allocate separate memory area so saves memory, and context-switching between the threads takes less time than process. Java Multithreading is mostly used in games, animation etc. Advantages of Java Multithreading 1) It doesn't block the user because threads are independent and you can perform multiple operations at same time. 2) You can perform many operations together so it saves time. 3) Threads are independent so it doesn't affect other threads if exception occur in a single thread. Java String In java, string is basically an object that represents sequence of char values. An array of characters works same as java string. For example: 1.char[] ch={'j','a','v','a','t','p','o','i','n','t'}; 2.String s=new String(ch);
  • 20. is same as: 1.String s="javatpoint"; Java String class provides a lot of methods to perform operations on string such as compare(), concat(), equals(), split(), length(), replace(), compareTo(), intern(), substring() etc. The java.lang.String class implements Serializable, Comparable and CharSequence i nterfaces. Java Inner Classes Java inner class or nested class is a class which is declared inside the class or interface. We use inner classes to logically group classes and interfaces in one place so that it can be more readable and maintainable. Additionally, it can access all the members of outer class including private data members and methods. Java Regex The Java Regex or Regular Expression is an API to define pattern for searching or manipulating strings. It is widely used to define constraint on strings such as password and email validation. After learning java regex tutorial, you will be able to test your own regular expressions by the Java Regex Tester Tool. Java Regex API provides 1 interface and 3 classes in java.util.regex package. java.util.regex package
  • 21. It provides following classes and interface for regular expressions. The Matcher and Pattern classes are widely used in java regular expression. 1.MatchResult interface 2.Matcher class 3.Pattern class 4.PatternSyntaxException class Generics in Java The Java Generics programming is introduced in J2SE 5 to deal with type-safe objects. Before generics, we can store any type of objects in collection i.e. non-generic. Now generics, forces the java programmer to store specific type of objects. Advantage of Java Generics There are mainly 3 advantages of generics. They are as follows: 1) Type-safety : We can hold only a single type of objects in generics. It doesn’t allow to store other objects. 2) Type casting is not required: There is no need to typecast the object. 3) Compile-Time Checking: It is checked at compile time so problem will not occur at runtime. The good programming strategy says it is far better to handle the problem at compile time than runtime.
  • 22. Collections in Java Collections in java are a framework that provides 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.). Java I/O Java I/O (Input and Output) is used to process the input and produce the output. Java uses the concept of stream to make I/O operation fast. The java.io package contains all the classes required for input and output operations. We can perform file handling in java by Java I/O API. Stream A stream is a sequence of data .In Java a stream is composed of bytes. It's called a stream because it is like a stream of water that continues to flow. In java, 3 streams are created for us automatically. All these streams are attached with console. 1) System.out: standard output stream
  • 23. 2) System.in: standard input stream 3) System.err: standard error stream OutputStream Java application uses an output stream to write data to a destination, it may be a file, an array, peripheral device or socket. InputStream Java application uses an input stream to read data from a source, it may be a file, an array, peripheral device or socket. Serialization in java Serialization in java is a mechanism of writing the state of an object into a byte stream .It is mainly used in Hibernate, RMI, JPA, EJB and JMS technologies .The reverse operation of serialization is called deserialization. Advantage of Java Serialization It is mainly used to travel object's state on the network (known as marshaling). Deserialization in java Deserialization is the process of reconstructing the object from the serialized state.It is the reverse operation of serialization.
  • 24. Java Socket Programming Java Socket programming is used for communication between the applications running on different JRE. Java Socket programming can be connection-oriented or connection-less. Socket and ServerSocket classes are used for connection-oriented socket programming and DatagramSocket and DatagramPacket classes are used for connection-less socket programming. The client in socket programming must know two information: 1.IP Address of Server, and 2.Port number.
  • 25. Socket class A socket is simply an endpoint for communications between the machines. The Socket class can be used to create a socket. Java JDBC Java JDBC is a java API to connect and execute query with the database. JDBC API uses jdbc drivers to connect with the database. Why use JDBC Before JDBC, ODBC API was the database API to connect and execute query with the database. But, ODBC API uses ODBC driver which is written in C language (i.e. platform dependent and unsecured). That is why Java has defined its own API (JDBC API) that uses JDBC drivers (written in Java language).
  • 26. CREATING A LAN (CLIENT -SERVER) CONNECTION VIA TCP/IP USING SOCKET PROGRAMMING IN JAVA Objective: The server and client present on different machines can have live chat until server says “stop” to terminate the connection. INTRODUCTION In this project, I have described the steps to make a connection in Java using Sockets. Let's start to understand what a communication link is created via TCP/IP. A communication link created via TCP/IP sockets is a connection-oriented link and is reliable. This means that the connection between the server and client remains open throughout the duration of the dialogue between the two and is only broken (under normal circumstances) when one end of the dialogue formally terminates the exchanges (like in our case when the clients says “stop”).
  • 27. FEATURES * Network based application having two faces: :> One for client :> One for server * It has two page source codes: one for server and one for client. * The machines are connected through a LAN cable. * The machines have jre n jdk files installed on them to run java code. STEPS ON SERVER SIDE * Establish a connection to the server. * Create a ServerSocket object. * Put the server into a waiting state. * Set up input and output streams. * Send and receive data. JAVA CODE ON SERVER SIDE import java.net.*; import java.io.*; class MyServer{
  • 28. public static void main(String args [])throws Exception{ ServerSocket ss=new ServerSocket(3333); Socket s=ss.accept(); DataInputStream din=new DataInputStream(s.getInputStream()); DataOutputStream dout=new DataOutputStream(s.getOutputStream()); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String str="",str2=""; while(!str.equals("stop")){ str=din.readUTF(); System.out.println("client says: "+str); str2=br.readLine(); dout.writeUTF(str2); dout.flush(); } din.close(); s.close(); ss.close(); }}
  • 29. STEPS ON CLIENT SIDE * Establish a connection to the server. * Set up input and output streams. * Send and receive data. * Close the connection. JAVA CODE ON CLIENT SIDE import java.net.*; import java.io.*; class MyClient{ public static void main(String args[])throws Exception{ Socket s=new Socket("localhost",3333); DataInputStream din=new DataInputStream(s.getInputStream()); DataOutputStream dout=new DataOutputStream(s.getOutputStream()); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String str="",str2=""; while(!str.equals("stop")){
  • 30. str=br.readLine(); dout.writeUTF(str); dout.flush(); str2=din.readUTF(); System.out.println ("Server says: "+str2); } dout.close(); s.close(); }} SCREENSHOTS SHOWING A GLIMPSE OF HOW THE CHAT WORKS * Bringing the client and server under the same network. :// Control Panel>Network and Internet>Network and Sharing Center>Ethernet
  • 32. :// Providing the IP Address * Code on server is compiled and run.
  • 33. * Code on client side is compiled and run. * Chat on client side
  • 34. * Chat on server side *Server asks client to terminate the chat.
  • 35. * Chat terminates when client says “stop”. EXTENSION This concept can be used for MULTIPLE CLIENT SERVER CHAT too using the concept of threads along with the ones used in the above project.
  • 36. SERIALISATION AND DESERIALISATION OF OBJECTS USING THE CONCEPT OF SERIALISATION AND DESREALISATION IN JAVA OBJECTIVE In this, there is a class and one program is trying to serialize it i.e. write it on a file and later some other program wants to it read it from the fie i.e. deserialise it and again get back to the same form. It’s kind of a mini project showing this concept in java. INTRODUCTION Serialization in java is a mechanism of writing the state of an object into a byte stream. Writing an object on file is serialization and reconstructing it from file is deserialization. The file that stores the object has extension .ser in this case the file is address.ser . In this implementation, the state of objects is printed in the order the objects are created.
  • 37. FEATURES * The class that’s implementing the built in class Serializable is Address. * The class that’s storing objects on the file is WriteObject.class. * The class that’s reading objects from the file is ReadObject.class. CODE FOR CLASS Address import java.io.Serializable; public class Address implements Serializable{ private static final long serialVersionUID = 1L; String street; String country; public void setStreet(String street) { this.street=street; } public void setCountry(String country) { this.country=country;
  • 38. } public String getStreet() { return this.street; } public String getCountry() { return this.country; } @Override public String toString() { return new StringBuffer("Street :") .append(this.street) .append("country :") .append(this.country).toString(); } }
  • 39. CODE FOR CLASS WriteObject import java.io.FileOutputStream; import java.io.ObjectOutputStream; public class WriteObject{ public static void main (String args[]) { Address address = new Address(); Address address2 = new Address(); address.setStreet("Delhi"); address.setCountry("india"); address2.setStreet("Del"); address2.setCountry("ina"); try { FileOutputStream fout = new FileOutputStream("address.ser"); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(address);
  • 40. oos.writeObject(address2); oos.close(); System.out.println("done"); } catch(Exception ex) { ex.printStackTrace(); } } } CODE FOR CLASS ReadObject import java.io.FileOutputStream; import java.io.ObjectOutputStream; public class WriteObject{ public static void main (String args[]) { Address address = new Address(); Address address2 = new Address(); address.setStreet("Delhi");
  • 41. address.setCountry("india"); address2.setStreet("Del"); address2.setCountry("ina"); try { FileOutputStream fout = new FileOutputStream("address.ser"); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(address); oos.writeObject(address2); oos.close(); System.out.println("done"); } catch(Exception ex) { ex.printStackTrace(); } } }
  • 42. SCREENSHOTS SHOWING THE OUTPUT :// Class Address is run.
  • 43. :// Code of WriteObject is run and compiled.
  • 44. :// Code for ReadObject is run and compiled.
  • 45. BIBLIOGRAPHY BOOKS >> The Complete Reference Java2 fifth edition (By :- Herbert Scheldt) >> Java Book by Balaguruswamy REFERENCES >>www.tutorilspoint.com/java >>www.allschoolstuff.com