SlideShare a Scribd company logo
Object 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).
13243967
java.io.Serializable interface
import java.io.Serializable;
public class Student implements Serializable
{
int id;
String name;
public Student(int id, String name) {
this.id = id;
this.name = name;
}
}
• In the above example, Student class implements Serializable
interface. Now its objects can be converted into stream.
ObjectOutputStream class
• The ObjectOutputStream class is used to write
primitive data types and Java objects to an
OutputStream. Only objects that support the
java.io.Serializable interface can be written to
streams.
import java.io.*;
class Depersist{
public static void main(String args[])throws Exception{
ObjectInputStream in=new ObjectInputStream(new FileInputStream("f.txt"))
;
Student s=(Student)in.readObject();
System.out.println(s.id+" "+s.name);
in.close();
}
}
OP : 211 ravi
Deserialization in java
• Deserialization is the process of reconstructing the object
from the serialized state.It is the reverse operation of
serialization.
ObjectInputStream class
• An ObjectInputStream deserializes objects and primitive data
written using an ObjectOutputStream.
Example of Java Deserialization
import java.io.*;
class Depersist{
public static void main(String args[])throws Exception{
ObjectInputStream in=new ObjectInputStream(new FileInputStream("f.txt"))
;
Student s=(Student)in.readObject();
System.out.println(s.id+" "+s.name);
in.close();
}
}
211 ravi
(Internet Inter-ORB Protocol)
• IIOP (Internet Inter-ORB Protocol) is a protocol
that makes it possible for distributed
programs written in different programming
languages to communicate over the Internet.
• The distributed Hello World example uses a
client application to make a remote method
call via IIOP to a server running on the host
from which the client was downloaded. When
the client runs, "Hello from MARS!" is
displayed.
• The steps to write the source files
• The steps to compile the example
• The steps to run the example
Write or Download the Source Files
There are three tasks to complete in this section:
• Define the functions of the remote class as an interface
written in the Java programming language
• Write the implementation class
• Write the server class
• Write a client program that uses the remote service
• The source files used in this tutorial are:
HelloInterface.java - a remote interface
• HelloImpl.java - a remote object implementation
that implements HelloInterface
• HelloServer.java - an RMI server that creates an
instance of the remote object implementation
and binds that instance to a name in the Naming
Service
• HelloClient.java - a client application that invokes
the remote method, sayHello()
13243967

More Related Content

PPT
Introducing object oriented programming (oop)
Hemlathadhevi Annadhurai
 
PDF
Python's dynamic nature (rough slides, November 2004)
Kiran Jonnalagadda
 
PPTX
Building maintainable web apps with Angular MS TechDays 2017
Erik van Appeldoorn
 
PPTX
Java
Abrar ali
 
PPTX
Architecture diagram of jvm
home
 
ODP
CORBA & RMI in java
S mahesh acharya
 
Introducing object oriented programming (oop)
Hemlathadhevi Annadhurai
 
Python's dynamic nature (rough slides, November 2004)
Kiran Jonnalagadda
 
Building maintainable web apps with Angular MS TechDays 2017
Erik van Appeldoorn
 
Java
Abrar ali
 
Architecture diagram of jvm
home
 
CORBA & RMI in java
S mahesh acharya
 

What's hot (19)

PPTX
Jsp tag library
sandeep54552
 
PPT
Java-java virtual machine
Surbhi Panhalkar
 
PPTX
Java ce241
Minal Maniar
 
PPT
Corba by Example
Roy Antony Arnold G
 
PPSX
Java & advanced java
BASAVARAJ HUNSHAL
 
PPT
Presentation On Com Dcom
Bharat Kumar Katur
 
PPTX
Java virtual machine
Dhanith Krishna
 
PDF
Java Virtual Machine - Internal Architecture
subnesh
 
PPT
Corba and-java
afreen58
 
PPT
Chapter 17 corba
AbDul ThaYyal
 
PPT
C sharp
Satish Verma
 
PPTX
Java features
Prashant Gajendra
 
PPT
Lecture4 corba
poovi117
 
PPTX
NiFi - First approach
Mickael Cassy
 
PPTX
Web-Dev Portfolio
nwbgh
 
PDF
Java8 features
Minal Maniar
 
PPTX
Introduction to Java Part-3
RatnaJava
 
PPTX
QSpiders - Memory (JVM architecture)
Qspiders - Software Testing Training Institute
 
Jsp tag library
sandeep54552
 
Java-java virtual machine
Surbhi Panhalkar
 
Java ce241
Minal Maniar
 
Corba by Example
Roy Antony Arnold G
 
Java & advanced java
BASAVARAJ HUNSHAL
 
Presentation On Com Dcom
Bharat Kumar Katur
 
Java virtual machine
Dhanith Krishna
 
Java Virtual Machine - Internal Architecture
subnesh
 
Corba and-java
afreen58
 
Chapter 17 corba
AbDul ThaYyal
 
C sharp
Satish Verma
 
Java features
Prashant Gajendra
 
Lecture4 corba
poovi117
 
NiFi - First approach
Mickael Cassy
 
Web-Dev Portfolio
nwbgh
 
Java8 features
Minal Maniar
 
Introduction to Java Part-3
RatnaJava
 
QSpiders - Memory (JVM architecture)
Qspiders - Software Testing Training Institute
 
Ad

Similar to 13243967 (20)

PPTX
Inter ORB Protocol and Object Persistence & Object Serialization
Ankit Mulani
 
PDF
Java Serialization
imypraz
 
PPS
Advance Java
Vidyacenter
 
PPT
Chapter10
lopjuan
 
PPTX
CHAPTER 5 mechanical engineeringasaaa.pptx
SadhilAggarwal
 
PPTX
Java Serialization Facts and Fallacies
Roman Elizarov
 
PDF
.NET Deserialization Attacks
Dharmalingam Ganesan
 
PPT
Advanced Java Topics
Salahaddin University-Erbil
 
PPTX
File Handling - Serialization.pptx
UsamaAshraf55
 
PPT
Java Basics
shivamgarg_nitj
 
PDF
[Distributed System] ch4. interprocess communication
Gyuhyeon Nam
 
PPT
CORBA.ppt
ssuser4fd4ff3
 
PDF
Abusing Java Remote Interfaces
juanvazquezslides
 
DOCX
Please look at the attach See.doc. I am getting this error all th.docx
randymartin91030
 
PPT
Network
phanleson
 
PDF
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
Checkmarx
 
PPTX
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
Dor Tumarkin
 
PPT
Distributed objects & components of corba
Mayuresh Wadekar
 
PPT
ADVANCED JAVA MODULE III & IV.ppt
rani marri
 
PPTX
Gulshan serialization inJava PPT ex.pptx
PRABHATMISHRA969924
 
Inter ORB Protocol and Object Persistence & Object Serialization
Ankit Mulani
 
Java Serialization
imypraz
 
Advance Java
Vidyacenter
 
Chapter10
lopjuan
 
CHAPTER 5 mechanical engineeringasaaa.pptx
SadhilAggarwal
 
Java Serialization Facts and Fallacies
Roman Elizarov
 
.NET Deserialization Attacks
Dharmalingam Ganesan
 
Advanced Java Topics
Salahaddin University-Erbil
 
File Handling - Serialization.pptx
UsamaAshraf55
 
Java Basics
shivamgarg_nitj
 
[Distributed System] ch4. interprocess communication
Gyuhyeon Nam
 
CORBA.ppt
ssuser4fd4ff3
 
Abusing Java Remote Interfaces
juanvazquezslides
 
Please look at the attach See.doc. I am getting this error all th.docx
randymartin91030
 
Network
phanleson
 
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
Checkmarx
 
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
Dor Tumarkin
 
Distributed objects & components of corba
Mayuresh Wadekar
 
ADVANCED JAVA MODULE III & IV.ppt
rani marri
 
Gulshan serialization inJava PPT ex.pptx
PRABHATMISHRA969924
 
Ad

Recently uploaded (20)

PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PDF
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PDF
Study Material and notes for Women Empowerment
ComputerScienceSACWC
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Study Material and notes for Women Empowerment
ComputerScienceSACWC
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 

13243967

  • 1. Object 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).
  • 3. java.io.Serializable interface import java.io.Serializable; public class Student implements Serializable { int id; String name; public Student(int id, String name) { this.id = id; this.name = name; } } • In the above example, Student class implements Serializable interface. Now its objects can be converted into stream.
  • 4. ObjectOutputStream class • The ObjectOutputStream class is used to write primitive data types and Java objects to an OutputStream. Only objects that support the java.io.Serializable interface can be written to streams.
  • 5. import java.io.*; class Depersist{ public static void main(String args[])throws Exception{ ObjectInputStream in=new ObjectInputStream(new FileInputStream("f.txt")) ; Student s=(Student)in.readObject(); System.out.println(s.id+" "+s.name); in.close(); } } OP : 211 ravi
  • 6. Deserialization in java • Deserialization is the process of reconstructing the object from the serialized state.It is the reverse operation of serialization. ObjectInputStream class • An ObjectInputStream deserializes objects and primitive data written using an ObjectOutputStream.
  • 7. Example of Java Deserialization import java.io.*; class Depersist{ public static void main(String args[])throws Exception{ ObjectInputStream in=new ObjectInputStream(new FileInputStream("f.txt")) ; Student s=(Student)in.readObject(); System.out.println(s.id+" "+s.name); in.close(); } } 211 ravi
  • 8. (Internet Inter-ORB Protocol) • IIOP (Internet Inter-ORB Protocol) is a protocol that makes it possible for distributed programs written in different programming languages to communicate over the Internet.
  • 9. • The distributed Hello World example uses a client application to make a remote method call via IIOP to a server running on the host from which the client was downloaded. When the client runs, "Hello from MARS!" is displayed.
  • 10. • The steps to write the source files • The steps to compile the example • The steps to run the example Write or Download the Source Files There are three tasks to complete in this section: • Define the functions of the remote class as an interface written in the Java programming language • Write the implementation class • Write the server class • Write a client program that uses the remote service
  • 11. • The source files used in this tutorial are: HelloInterface.java - a remote interface • HelloImpl.java - a remote object implementation that implements HelloInterface • HelloServer.java - an RMI server that creates an instance of the remote object implementation and binds that instance to a name in the Naming Service • HelloClient.java - a client application that invokes the remote method, sayHello()