SlideShare a Scribd company logo
Advanced Java Programming
Topic: Distributed Programming (RMI)

By
Ravi Kant Sahu
Asst. Professor, LPU
Remote method INVoCAtIoN
(RMI)

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Introduction


RMI is a mechanism for communicating (only) between two
machines running Java Virtual Machines.



When Java code on machine A needs a service or a method,
respectively, of (remote Java object) objB on machine B it starts
a remote method invocation.



It does this the same way as invoking a local (Java) object's
method.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Method Invocation


Java RMI is a mechanism that allows one to invoke a method on
an object that exists in another address space.



The other address space could be on the same machine or a
different one.



The RMI mechanism is basically an object-oriented RPC
mechanism.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
RMI ARchItectuRe

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Communication


RMI allows an object to invoke methods on an object running in
another JVM.



RMI provides remote communication between the applications
using two objects:
1. Stub
2. Skeleton



A remote object is an object whose method can be invoked from
another JVM.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Understanding Stub and Skeleton

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Stub



Stub is an object which acts as a gateway for the client side.
All the outgoing requests are routed through Stub.
It represents the remote object at the client side.



Stub performs the following tasks:




1. It initiates a connection with remote JVM.
2. It writes and transmits the parameters to remote JVM
(Marshaling).
3. It reads the returned value or exception (Unmarshaling).
4. Finally, returns the result to the Caller.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Skeleton


Skeleton is an object which acts as a gateway for the srver side.



All the outgoing requests are routed through Stub.



Skeleton performs the following tasks:
1. It reads the parameters for the remote method.
2. It reads the parameters from caller (Unmarshaling).
3. It invokes the method on the actual remote object.
4. It writes and transmits the result to the caller (Marshaling).

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Writing rMi ApplicAtions

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Writing RMI Programs
Steps to write RMI program:
1. Create a remote Interface.
2. Provide implementation of the remote interface (Remote
class).
3. Compile the implementation class and create the stub and
skeleton objects using rmic tool (rmic remoteclass).
4. Start the registry service by rmiregistry tool (start rmiregistry).
5. Create and start the remote application.
6. Create and start the client application.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote InteRface & class

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Class


A Remote class has two parts: the interface and the class itself.

Remote Interface:
The Remote interface must have the following properties:
1. The interface must be public.
2. The interface must extend the interface java.rmi.Remote.
3. Every method in the interface must declare that it throws
java.rmi.RemoteException. Other exceptions may also be
thrown.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Interface
import java.rmi.*;
public interface RemoteInterface extends Remote
{
double sum(double d1, double d2) throws RemoteException;
}

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Class


The Remote class itself has the following properties:
1. It must implement a Remote interface.
2. It should extend the java.rmi.server.UnicastRemoteObject
class.
3. It can have methods that are not in its Remote interface. These
can only be invoked locally.

Note: Objects of such a class exist in the address space of the
server and can be invoked remotely.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Class
import java.rmi.*;
import java.rmi.server.*;
public class RemoteClass extends UnicastRemoteObject implements
RemoteInterface
{
public RemoteClass() throws RemoteException
{}
public double sum(double d1, double d2) throws RemoteException
{
return d1 + d2;
}
}
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Distributed Programming (RMI)

More Related Content

What's hot (20)

Java interview questions 1
Java interview questions 1Java interview questions 1
Java interview questions 1
Sherihan Anver
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
Hari kiran G
 
Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2
Sherihan Anver
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
İbrahim Kürce
 
Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014
iimjobs and hirist
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructor
Shivam Singhal
 
Java se 8 fundamentals
Java se 8 fundamentalsJava se 8 fundamentals
Java se 8 fundamentals
megharajk
 
Core java
Core javaCore java
Core java
Shivaraj R
 
Java notes
Java notesJava notes
Java notes
Upasana Talukdar
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
Math-Circle
 
Core Java
Core JavaCore Java
Core Java
Prakash Dimmita
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
Kuntal Bhowmick
 
Java reflection
Java reflectionJava reflection
Java reflection
NexThoughts Technologies
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
İbrahim Kürce
 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
shashi shekhar
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
Ravi Kant Sahu
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsOCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIs
İbrahim Kürce
 
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfJAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
nofakeNews
 
Lecture 3 java basics
Lecture 3 java basicsLecture 3 java basics
Lecture 3 java basics
the_wumberlog
 
Core java lessons
Core java lessonsCore java lessons
Core java lessons
vivek shah
 
Java interview questions 1
Java interview questions 1Java interview questions 1
Java interview questions 1
Sherihan Anver
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
Hari kiran G
 
Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2
Sherihan Anver
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
İbrahim Kürce
 
Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014
iimjobs and hirist
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructor
Shivam Singhal
 
Java se 8 fundamentals
Java se 8 fundamentalsJava se 8 fundamentals
Java se 8 fundamentals
megharajk
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
Math-Circle
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
Kuntal Bhowmick
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
İbrahim Kürce
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
Ravi Kant Sahu
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsOCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIs
İbrahim Kürce
 
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfJAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
nofakeNews
 
Lecture 3 java basics
Lecture 3 java basicsLecture 3 java basics
Lecture 3 java basics
the_wumberlog
 
Core java lessons
Core java lessonsCore java lessons
Core java lessons
vivek shah
 

Viewers also liked (12)

Internationalization
InternationalizationInternationalization
Internationalization
Ravi Kant Sahu
 
Basic IO
Basic IOBasic IO
Basic IO
Ravi_Kant_Sahu
 
Collection framework
Collection frameworkCollection framework
Collection framework
Ravi_Kant_Sahu
 
Jdbc
JdbcJdbc
Jdbc
Ravi_Kant_Sahu
 
Questions for Class I & II
Questions for Class I & IIQuestions for Class I & II
Questions for Class I & II
Saloni Jaiswal
 
Event handling
Event handlingEvent handling
Event handling
Ravi Kant Sahu
 
Servlets
ServletsServlets
Servlets
Ravi Kant Sahu
 
List classes
List classesList classes
List classes
Ravi_Kant_Sahu
 
Sms several papers
Sms several papersSms several papers
Sms several papers
Arjun Shanka
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in Java
Ravi_Kant_Sahu
 
Generics
GenericsGenerics
Generics
Ravi_Kant_Sahu
 
Ad

Similar to Distributed Programming (RMI) (20)

Rmi
RmiRmi
Rmi
Vijay Kiran
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
Veni7
 
Rmi
RmiRmi
Rmi
Mallikarjuna G D
 
Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
sakthibalabalamuruga
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
Dew Shishir
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
Thesis Scientist Private Limited
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
Jalpesh Vasa
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
Sonali Parab
 
Rmi
RmiRmi
Rmi
vantinhkhuc
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
Sonali Parab
 
Rmi architecture
Rmi architectureRmi architecture
Rmi architecture
Maulik Desai
 
ADB Lab Manual.docx
ADB Lab Manual.docxADB Lab Manual.docx
ADB Lab Manual.docx
SaiKumarPrajapathi
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVA
Prankit Mishra
 
Java rmi tutorial
Java rmi tutorialJava rmi tutorial
Java rmi tutorial
HarikaReddy115
 
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)
shraddha mane
 
Rmi presentation
Rmi presentationRmi presentation
Rmi presentation
Azad public school
 
Introduction To Rmi
Introduction To RmiIntroduction To Rmi
Introduction To Rmi
SwarupKulkarni
 
#4 (Remote Method Invocation)
#4 (Remote Method Invocation)#4 (Remote Method Invocation)
#4 (Remote Method Invocation)
Ghadeer AlHasan
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
Gera Paulos
 
Java RMI
Java RMIJava RMI
Java RMI
Ankit Desai
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
Veni7
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
Dew Shishir
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
Jalpesh Vasa
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
Sonali Parab
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
Sonali Parab
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVA
Prankit Mishra
 
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)
shraddha mane
 
#4 (Remote Method Invocation)
#4 (Remote Method Invocation)#4 (Remote Method Invocation)
#4 (Remote Method Invocation)
Ghadeer AlHasan
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
Gera Paulos
 
Ad

Recently uploaded (20)

vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 

Distributed Programming (RMI)

  • 1. Advanced Java Programming Topic: Distributed Programming (RMI) By Ravi Kant Sahu Asst. Professor, LPU
  • 2. Remote method INVoCAtIoN (RMI) Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 3. Introduction  RMI is a mechanism for communicating (only) between two machines running Java Virtual Machines.  When Java code on machine A needs a service or a method, respectively, of (remote Java object) objB on machine B it starts a remote method invocation.  It does this the same way as invoking a local (Java) object's method. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 4. Remote Method Invocation  Java RMI is a mechanism that allows one to invoke a method on an object that exists in another address space.  The other address space could be on the same machine or a different one.  The RMI mechanism is basically an object-oriented RPC mechanism. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 5. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 6. RMI ARchItectuRe Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 7. Remote Communication  RMI allows an object to invoke methods on an object running in another JVM.  RMI provides remote communication between the applications using two objects: 1. Stub 2. Skeleton  A remote object is an object whose method can be invoked from another JVM. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 8. Understanding Stub and Skeleton Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 9. Stub  Stub is an object which acts as a gateway for the client side. All the outgoing requests are routed through Stub. It represents the remote object at the client side.  Stub performs the following tasks:   1. It initiates a connection with remote JVM. 2. It writes and transmits the parameters to remote JVM (Marshaling). 3. It reads the returned value or exception (Unmarshaling). 4. Finally, returns the result to the Caller. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 10. Skeleton  Skeleton is an object which acts as a gateway for the srver side.  All the outgoing requests are routed through Stub.  Skeleton performs the following tasks: 1. It reads the parameters for the remote method. 2. It reads the parameters from caller (Unmarshaling). 3. It invokes the method on the actual remote object. 4. It writes and transmits the result to the caller (Marshaling). Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 11. Writing rMi ApplicAtions Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 12. Writing RMI Programs Steps to write RMI program: 1. Create a remote Interface. 2. Provide implementation of the remote interface (Remote class). 3. Compile the implementation class and create the stub and skeleton objects using rmic tool (rmic remoteclass). 4. Start the registry service by rmiregistry tool (start rmiregistry). 5. Create and start the remote application. 6. Create and start the client application. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 13. Remote InteRface & class Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 14. Remote Class  A Remote class has two parts: the interface and the class itself. Remote Interface: The Remote interface must have the following properties: 1. The interface must be public. 2. The interface must extend the interface java.rmi.Remote. 3. Every method in the interface must declare that it throws java.rmi.RemoteException. Other exceptions may also be thrown. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 15. Remote Interface import java.rmi.*; public interface RemoteInterface extends Remote { double sum(double d1, double d2) throws RemoteException; } Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 16. Remote Class  The Remote class itself has the following properties: 1. It must implement a Remote interface. 2. It should extend the java.rmi.server.UnicastRemoteObject class. 3. It can have methods that are not in its Remote interface. These can only be invoked locally. Note: Objects of such a class exist in the address space of the server and can be invoked remotely. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 17. Remote Class import java.rmi.*; import java.rmi.server.*; public class RemoteClass extends UnicastRemoteObject implements RemoteInterface { public RemoteClass() throws RemoteException {} public double sum(double d1, double d2) throws RemoteException { return d1 + d2; } } Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)