SlideShare a Scribd company logo
1 of 18
Manimozhi
Vijay Kiran
Whats RMI ??
The Java Remote Method Invocation
Application Programming Interface (API),
Java RMI, is a Java API that performs the
object-oriented equivalent of remote
procedure calls (RPC), with support for
direct transfer of Java objects over a
distributed network.
RMI Vs RPC
RPC is C based, and as such it has structured
programming semantics, on the other side,
 RMI is a Java based technology and it's object oriented
and can be used for complex applications.
With RPC you can just call remote functions exported into
a server,
 RMI you can have references to remote objects and
invoke their methods, and also pass and return more
remote object references that can be distributed among
many JVM instances, so it's much more powerful.
Sockets Vs RMI
If your programming games, chat programs,
streaming media, file transfer use sockets
and read/write bytes. You have tighter control
over what is sent, you can optimize the
streams, by buffering, or compressing date.
If you programming business applications
which require remote method calls, use RMI.
Corba however would be useless for lets say,
file transfer, or any streaming type app.
Architecture
Working of RMI
Marshalling
During communication between two machines
through RPC or RMI, parameters are packed
into a message and then sent over the network.
This packing of parameters into a message is
called marshalling.
On the other side these packed parameters are
unpacked from the message which is called
unmarshalling.
RMI Application Development
Steps for Developing the RMI Application
• Define the remote interface
• Define the class and implement the remote
interface(methods) in this class
• Define the Server side class
• Define the Client side class
• Compile the all four source(java) files
• Generate the Stub/Skeleton class by command
• Start the RMI remote Registry
• Run the Server side class
• Run the Client side class(at another JVM)
(1) Define the remote interface:
 This is an interface in which we are declaring
the methods as per our logic and further
these methods will be called using RMI.
 (2) Define the class and implement the
remote interface(methods) in this class:
 The next step is to implement the interface
so define a class(ServerImpl.java) and
implements the interface(Vinterface.java) so
now in the class we must define the body of
those methods.This class run on the remote
server.
(3) Define the Server side class:
 The server must bind its name to the registry by passing the
reference link with remote object name.
 For that here we are going to use rebind method which has two
arguments:
 The first parameter is a URL to a registry that includes the name
of the application and The second parameter is an object name
that is access remotely in between the client and server.
 This rebind method is a method of the Naming class which is
available in the java.rmi.* package.
 The server name is specified in URL as a application name and
here the name is (ServerImp) in our application.
Note:
 The general form of the URL:
 rmi://localhost:port/application_name
 Here, 1099 is the default RMI port and
127.0.0.1 is a localhost-ip address.
(4) Define the Client side class:
 To access an object remotely by client side
that is already bind at a server side by one
reference URL we use the lookup method
which has one argument that is a same
reference URL as already applied at server
side class.
 This lookup method is a method of the
Naming class which is available in the
java.rmi.* package.
(5) Compile the all four source(java) files:
 javac InterfaceFile.java
 javac InterfaceFileImpl.java
 javac Client.java
 javac Server.java
After compiled, in the folder we can see the four
class files such as
 InterfaceFile.class , InterfaceFileImpl.class
 Client.class , Server.class
(6) Generate the Stub/Skeleton class by
command:
 There is a command rmic by which we can
generate a Stub/Skeleton class.
 Syntax:
 rmic class_name
 Here the class_name is a java file in which
the all methods are defined so in this
application the class name
is ServerImpl.java file.
(7) Start the RMI remote Registry:
 The references of the objects are registered
into the RMI Registry So now you need to
start the RMI registry for that use the
command
 start rmiregistry
 So the system will open rmiregistry.exe (like
a blank command prompt)
(8) Run the Server side class:
 Now you need to run the RMI Server class.
(9) Run the Client side class(at another JVM):
 Now open a new command prompt for the client
because current command prompt working as a
server and finally run the RMI client class.
 Here Client.java file is a working as a Client so
finally run this fie.
 java Client
Demo time

More Related Content

What's hot

Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMI
backdoor
 
Java remote method invocation
Java remote method invocationJava remote method invocation
Java remote method invocation
Van Dawn
 
remote method invocation
remote method invocationremote method invocation
remote method invocation
Ravi Theja
 

What's hot (20)

Java rmi
Java rmiJava rmi
Java rmi
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 
RMI
RMIRMI
RMI
 
Rmi architecture
Rmi architectureRmi architecture
Rmi architecture
 
Java RMI Detailed Tutorial
Java RMI Detailed TutorialJava RMI Detailed Tutorial
Java RMI Detailed Tutorial
 
Introduction To Rmi
Introduction To RmiIntroduction To Rmi
Introduction To Rmi
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Rmi
RmiRmi
Rmi
 
Java rmi
Java rmiJava rmi
Java rmi
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
 
Rmi ppt-2003
Rmi ppt-2003Rmi ppt-2003
Rmi ppt-2003
 
Rmi
RmiRmi
Rmi
 
Java RMI
Java RMIJava RMI
Java RMI
 
Java rmi tutorial
Java rmi tutorialJava rmi tutorial
Java rmi tutorial
 
Java RMI Presentation
Java RMI PresentationJava RMI Presentation
Java RMI Presentation
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMI
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
 
Java remote method invocation
Java remote method invocationJava remote method invocation
Java remote method invocation
 
Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)
 
remote method invocation
remote method invocationremote method invocation
remote method invocation
 

Viewers also liked

Comparacion Entre Rmi Y Api De Sockets
Comparacion Entre Rmi Y Api De SocketsComparacion Entre Rmi Y Api De Sockets
Comparacion Entre Rmi Y Api De Sockets
mallita
 
Comparison between-rpc-rmi-and-webservices-son-1228374226080667-8
Comparison between-rpc-rmi-and-webservices-son-1228374226080667-8Comparison between-rpc-rmi-and-webservices-son-1228374226080667-8
Comparison between-rpc-rmi-and-webservices-son-1228374226080667-8
helpsoft01
 
Distributes objects and Rmi
Distributes objects and RmiDistributes objects and Rmi
Distributes objects and Rmi
Mayank Jain
 
Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with code
kamal kotecha
 

Viewers also liked (11)

Comparacion Entre Rmi Y Api De Sockets
Comparacion Entre Rmi Y Api De SocketsComparacion Entre Rmi Y Api De Sockets
Comparacion Entre Rmi Y Api De Sockets
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Comparison between-rpc-rmi-and-webservices-son-1228374226080667-8
Comparison between-rpc-rmi-and-webservices-son-1228374226080667-8Comparison between-rpc-rmi-and-webservices-son-1228374226080667-8
Comparison between-rpc-rmi-and-webservices-son-1228374226080667-8
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Olap, oltp and data mining
Olap, oltp and data miningOlap, oltp and data mining
Olap, oltp and data mining
 
Distributes objects and Rmi
Distributes objects and RmiDistributes objects and Rmi
Distributes objects and Rmi
 
Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with code
 
Overview of big data in cloud computing
Overview of big data in cloud computingOverview of big data in cloud computing
Overview of big data in cloud computing
 
OLAP
OLAPOLAP
OLAP
 
Java - Remote method invocation
Java - Remote method invocationJava - Remote method invocation
Java - Remote method invocation
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging Challenges
 

Similar to Rmi

Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMI
backdoor
 
Distributed Objects and JAVA
Distributed Objects and JAVADistributed Objects and JAVA
Distributed Objects and JAVA
elliando dias
 

Similar to Rmi (19)

Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 
Oracle docs rmi applications
Oracle docs rmi applicationsOracle docs rmi applications
Oracle docs rmi applications
 
Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMI
 
Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01
 
DS
DSDS
DS
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
 
Java RMI
Java RMIJava RMI
Java RMI
 
ADB Lab Manual.docx
ADB Lab Manual.docxADB Lab Manual.docx
ADB Lab Manual.docx
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Report on mini project(Student database handling using RMI)
Report on mini project(Student database handling using RMI)Report on mini project(Student database handling using RMI)
Report on mini project(Student database handling using RMI)
 
Module 3 remote method invocation-2
Module 3   remote method  invocation-2Module 3   remote method  invocation-2
Module 3 remote method invocation-2
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
 
Rmi
RmiRmi
Rmi
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Rmi
RmiRmi
Rmi
 
Rmi
RmiRmi
Rmi
 
Distributed Objects and JAVA
Distributed Objects and JAVADistributed Objects and JAVA
Distributed Objects and JAVA
 
Java interview questions for freshers
Java interview questions for freshersJava interview questions for freshers
Java interview questions for freshers
 
Basic java
Basic java Basic java
Basic java
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 

Rmi

  • 2. Whats RMI ?? The Java Remote Method Invocation Application Programming Interface (API), Java RMI, is a Java API that performs the object-oriented equivalent of remote procedure calls (RPC), with support for direct transfer of Java objects over a distributed network.
  • 3. RMI Vs RPC RPC is C based, and as such it has structured programming semantics, on the other side,  RMI is a Java based technology and it's object oriented and can be used for complex applications. With RPC you can just call remote functions exported into a server,  RMI you can have references to remote objects and invoke their methods, and also pass and return more remote object references that can be distributed among many JVM instances, so it's much more powerful.
  • 4. Sockets Vs RMI If your programming games, chat programs, streaming media, file transfer use sockets and read/write bytes. You have tighter control over what is sent, you can optimize the streams, by buffering, or compressing date. If you programming business applications which require remote method calls, use RMI. Corba however would be useless for lets say, file transfer, or any streaming type app.
  • 7. Marshalling During communication between two machines through RPC or RMI, parameters are packed into a message and then sent over the network. This packing of parameters into a message is called marshalling. On the other side these packed parameters are unpacked from the message which is called unmarshalling.
  • 8. RMI Application Development Steps for Developing the RMI Application • Define the remote interface • Define the class and implement the remote interface(methods) in this class • Define the Server side class • Define the Client side class • Compile the all four source(java) files • Generate the Stub/Skeleton class by command • Start the RMI remote Registry • Run the Server side class • Run the Client side class(at another JVM)
  • 9. (1) Define the remote interface:  This is an interface in which we are declaring the methods as per our logic and further these methods will be called using RMI.
  • 10.  (2) Define the class and implement the remote interface(methods) in this class:  The next step is to implement the interface so define a class(ServerImpl.java) and implements the interface(Vinterface.java) so now in the class we must define the body of those methods.This class run on the remote server.
  • 11. (3) Define the Server side class:  The server must bind its name to the registry by passing the reference link with remote object name.  For that here we are going to use rebind method which has two arguments:  The first parameter is a URL to a registry that includes the name of the application and The second parameter is an object name that is access remotely in between the client and server.  This rebind method is a method of the Naming class which is available in the java.rmi.* package.  The server name is specified in URL as a application name and here the name is (ServerImp) in our application.
  • 12. Note:  The general form of the URL:  rmi://localhost:port/application_name  Here, 1099 is the default RMI port and 127.0.0.1 is a localhost-ip address.
  • 13. (4) Define the Client side class:  To access an object remotely by client side that is already bind at a server side by one reference URL we use the lookup method which has one argument that is a same reference URL as already applied at server side class.  This lookup method is a method of the Naming class which is available in the java.rmi.* package.
  • 14. (5) Compile the all four source(java) files:  javac InterfaceFile.java  javac InterfaceFileImpl.java  javac Client.java  javac Server.java After compiled, in the folder we can see the four class files such as  InterfaceFile.class , InterfaceFileImpl.class  Client.class , Server.class
  • 15. (6) Generate the Stub/Skeleton class by command:  There is a command rmic by which we can generate a Stub/Skeleton class.  Syntax:  rmic class_name  Here the class_name is a java file in which the all methods are defined so in this application the class name is ServerImpl.java file.
  • 16. (7) Start the RMI remote Registry:  The references of the objects are registered into the RMI Registry So now you need to start the RMI registry for that use the command  start rmiregistry  So the system will open rmiregistry.exe (like a blank command prompt)
  • 17. (8) Run the Server side class:  Now you need to run the RMI Server class. (9) Run the Client side class(at another JVM):  Now open a new command prompt for the client because current command prompt working as a server and finally run the RMI client class.  Here Client.java file is a working as a Client so finally run this fie.  java Client