SlideShare a Scribd company logo
1 of 4
JAVA RMI – INTRODUCTION
RMI stands for Remote Method Invocation. It is a mechanism that allows an object residing in one
systemto access/invoke anobject running on another JVM.
RMI is used to build distributedapplications; it providesremote communication between Java
programs. It is providedin the package java.rmi.
Architecture of an RMI Application
In an RMI application, we write two programs, a server programand a client program.
Inside the server program, a remote object is createdand reference of that object is made available
for the client .
The client program requeststhe remote objectson the server and tries to invoke its methods.
The following diagram shows the architecture of an RMI application.
Let us now discuss the componentsof this architecture.
Transport Layer − Thislayer connectsthe client and the server. It manages the existing connection
and
also sets up new connections.
Stub − A stub is a representationof the remote object at client. It resides in the client system; it acts
as a gateway for the client program.
JVM
residesontheserver
residesontheclient
usingtheregistry
Skeleton− This is the object which resides on the server side. stub communicateswith this skeleton
to pass request to the remote object.
RRL − It is the layer which manages the referencesmade by the client to the remote object.
Working of an RMI Application
The following points summarize how an RMI application works−
When the client makes a callto the remote object, it is receivedby the stub which eventually passes
this request to the RRL.
When the client-side RRL receivesthe request, it invokesa method called invoke of the object
remoteRef. It passes the request to the RRL on the server side.
The RRL on the server side passes the request to the Skeletonwhich finally invokesthe
requiredobject on the server.
The result is passed all the way back to the client.
Marshalling and Unmarshalling
Whenever a client invokesa method that acceptsparameters on a remote object, the parameters are
bundled intoa message before being sent over the network. These parameters may be of primitive
type or objects. Incase of primitive type, the parametersare put together and a header is attached to
it. In case the parameters are objects, then they are serialized. Thisprocessis known as marshalling.
At the server side, the packed parametersare unbundled and then the required method is invoked.
Thisprocessis known as unmarshalling.
RMI Registry
RMI registry is a namespace on which all server objectsare placed. Each time the server createsan
object, it registersthis object with the RMIregistry (using bind or reBind methods). These are
registeredusing a unique name known as bind name.
To invoke a remote object, the client needs a reference of that object. At that time, the client fetches
the object from the registry using its bind name (using lookupmethod).
The following illustration explains the entire process−
RemoteReferenceLayer proxyontheserver
Goals of RMI
Following are the goals of RMI −
To minimize the complexity of the application.
To preserve type safety.
Distributed garbage collection.
Minimize the difference between working with localand remote objects.
To developan RMI Application we require the followingclasses and interfaces.
1.interface
2.Implementation class
3.Server Application
4.Client Application.
Defining Interface.
Add.java
import java.rmi.*;
public interface Addextends Remote
{
public int sum(int a,int b) throws RemoteException;
}
DefiningImplementationClass.
AddImpl.java
importjava.rmi.*;
importjava.rmi.server.*;
publicclassAddImpl extendsUnicastRemoteObjectimplementsAdd
{
publicAddImpl()throwsRemoteException
{
super();
}
publicintsum(inta,intb) throwsRemoteException
{
intc=a+b;
returnc;
}
}
ServerProgram
AddServer.java
importjava.rmi.*;
importjava.rmi.server.*;
publicclassAddServer
{
publicstaticvoidmain(Stringargs[])
{
tTry
{
Addob=newAddImpl();
Naming.rebind(“khaja”,ob);
System.out.println(“Serverready”);
}
catch(Exceptione)
{
System.out.println(e);
}
}
}
ClientProgram
AddClient.java
importjava.rmi.*;
importjava.util.*;
publicclassAddClient
{
publicstaticvoidmain(Stringargs[])
{
try
{
Addob=(Add)Naming.lookup(“khaja”);
Scannersc=newScanner(System.in);
System.out.println(“Enterthe FirstNumber“);
inta=sc.nextInt();
System.out.println(“Enterthe Second Number“);
intb=sc.nextInt();
intc=ob.sum(a,b);
System.out.println(“sum=”+c);
}
catch(Exceptione)
{
System.out.println(e);
}
}
}
CompilationandExecutionSteps
Step1:compile 4 .javafiles
Step2:create stubsandskeleton(optional fromjdk1.5)
>rmic AddImpl
Step3:startrmiregistry
>start rmiregistry
Step4:startserver
>start javaAddServer
Step5:Run Client
>javaAddClient

More Related Content

What's hot

What's hot (17)

Rmi
RmiRmi
Rmi
 
Java RMI
Java RMIJava RMI
Java RMI
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVA
 
Rmi
RmiRmi
Rmi
 
Java rmi
Java rmiJava rmi
Java rmi
 
DS
DSDS
DS
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
 
Java RMI Detailed Tutorial
Java RMI Detailed TutorialJava RMI Detailed Tutorial
Java RMI Detailed Tutorial
 
RMI
RMIRMI
RMI
 
Rmi
RmiRmi
Rmi
 
Architectural Patterns - Interactive and Event Handling Patterns
Architectural Patterns  - Interactive and Event Handling PatternsArchitectural Patterns  - Interactive and Event Handling Patterns
Architectural Patterns - Interactive and Event Handling Patterns
 
remote method invocation
remote method invocationremote method invocation
remote method invocation
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 
Java rmi
Java rmiJava rmi
Java rmi
 
Opendaylight overview
Opendaylight overviewOpendaylight overview
Opendaylight overview
 
Active Object Design Pattern
Active Object Design PatternActive Object Design Pattern
Active Object Design Pattern
 
Rmi
RmiRmi
Rmi
 

Similar to Java rmi

Java RMI(Remote Method Invocation)
Java RMI(Remote Method Invocation)Java RMI(Remote Method Invocation)
Java RMI(Remote Method Invocation)Nilesh Valva
 
Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01heenamithadiya
 
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
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocationashishspace
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocationDew Shishir
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingGera Paulos
 
A Short Java RMI Tutorial
A Short Java RMI TutorialA Short Java RMI Tutorial
A Short Java RMI TutorialGuo Albert
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method InvocationSonali Parab
 
DS R16 - UNIT-3.pdf
DS R16 - UNIT-3.pdfDS R16 - UNIT-3.pdf
DS R16 - UNIT-3.pdfVarshaBaini
 
#4 (Remote Method Invocation)
#4 (Remote Method Invocation)#4 (Remote Method Invocation)
#4 (Remote Method Invocation)Ghadeer AlHasan
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method InvocationSabiha M
 

Similar to Java rmi (20)

Java RMI(Remote Method Invocation)
Java RMI(Remote Method Invocation)Java RMI(Remote Method Invocation)
Java RMI(Remote Method Invocation)
 
Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01
 
Distributed objects
Distributed objectsDistributed objects
Distributed objects
 
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)
 
Oracle docs rmi applications
Oracle docs rmi applicationsOracle docs rmi applications
Oracle docs rmi applications
 
Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Activation
ActivationActivation
Activation
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
 
Remoting and serialization
Remoting and serializationRemoting and serialization
Remoting and serialization
 
A Short Java RMI Tutorial
A Short Java RMI TutorialA Short Java RMI Tutorial
A Short Java RMI Tutorial
 
Rmi
RmiRmi
Rmi
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
DS R16 - UNIT-3.pdf
DS R16 - UNIT-3.pdfDS R16 - UNIT-3.pdf
DS R16 - UNIT-3.pdf
 
#4 (Remote Method Invocation)
#4 (Remote Method Invocation)#4 (Remote Method Invocation)
#4 (Remote Method Invocation)
 
javarmi
javarmijavarmi
javarmi
 
Rmi presentation
Rmi presentationRmi presentation
Rmi presentation
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 

Recently uploaded

Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsApsara Of India
 
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...lizamodels9
 
2024 Numerator Consumer Study of Cannabis Usage
2024 Numerator Consumer Study of Cannabis Usage2024 Numerator Consumer Study of Cannabis Usage
2024 Numerator Consumer Study of Cannabis UsageNeil Kimberley
 
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurVIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurSuhani Kapoor
 
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptxBanana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptxgeorgebrinton95
 
Progress Report - Oracle Database Analyst Summit
Progress  Report - Oracle Database Analyst SummitProgress  Report - Oracle Database Analyst Summit
Progress Report - Oracle Database Analyst SummitHolger Mueller
 
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
Tech Startup Growth Hacking 101  - Basics on Growth MarketingTech Startup Growth Hacking 101  - Basics on Growth Marketing
Tech Startup Growth Hacking 101 - Basics on Growth MarketingShawn Pang
 
BEST Call Girls In BELLMONT HOTEL ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In BELLMONT HOTEL ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In BELLMONT HOTEL ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In BELLMONT HOTEL ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,noida100girls
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessAggregage
 
Non Text Magic Studio Magic Design for Presentations L&P.pptx
Non Text Magic Studio Magic Design for Presentations L&P.pptxNon Text Magic Studio Magic Design for Presentations L&P.pptx
Non Text Magic Studio Magic Design for Presentations L&P.pptxAbhayThakur200703
 
A.I. Bot Summit 3 Opening Keynote - Perry Belcher
A.I. Bot Summit 3 Opening Keynote - Perry BelcherA.I. Bot Summit 3 Opening Keynote - Perry Belcher
A.I. Bot Summit 3 Opening Keynote - Perry BelcherPerry Belcher
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.Aaiza Hassan
 
CATALOG cáp điện Goldcup (bảng giá) 1.4.2024.PDF
CATALOG cáp điện Goldcup (bảng giá) 1.4.2024.PDFCATALOG cáp điện Goldcup (bảng giá) 1.4.2024.PDF
CATALOG cáp điện Goldcup (bảng giá) 1.4.2024.PDFOrient Homes
 
rishikeshgirls.in- Rishikesh call girl.pdf
rishikeshgirls.in- Rishikesh call girl.pdfrishikeshgirls.in- Rishikesh call girl.pdf
rishikeshgirls.in- Rishikesh call girl.pdfmuskan1121w
 
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCRsoniya singh
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...lizamodels9
 
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / NcrCall Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncrdollysharma2066
 
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailCase study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailAriel592675
 
Marketing Management Business Plan_My Sweet Creations
Marketing Management Business Plan_My Sweet CreationsMarketing Management Business Plan_My Sweet Creations
Marketing Management Business Plan_My Sweet Creationsnakalysalcedo61
 

Recently uploaded (20)

Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
 
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
 
2024 Numerator Consumer Study of Cannabis Usage
2024 Numerator Consumer Study of Cannabis Usage2024 Numerator Consumer Study of Cannabis Usage
2024 Numerator Consumer Study of Cannabis Usage
 
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurVIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
 
KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)
 
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptxBanana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptx
 
Progress Report - Oracle Database Analyst Summit
Progress  Report - Oracle Database Analyst SummitProgress  Report - Oracle Database Analyst Summit
Progress Report - Oracle Database Analyst Summit
 
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
Tech Startup Growth Hacking 101  - Basics on Growth MarketingTech Startup Growth Hacking 101  - Basics on Growth Marketing
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
 
BEST Call Girls In BELLMONT HOTEL ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In BELLMONT HOTEL ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In BELLMONT HOTEL ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In BELLMONT HOTEL ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for Success
 
Non Text Magic Studio Magic Design for Presentations L&P.pptx
Non Text Magic Studio Magic Design for Presentations L&P.pptxNon Text Magic Studio Magic Design for Presentations L&P.pptx
Non Text Magic Studio Magic Design for Presentations L&P.pptx
 
A.I. Bot Summit 3 Opening Keynote - Perry Belcher
A.I. Bot Summit 3 Opening Keynote - Perry BelcherA.I. Bot Summit 3 Opening Keynote - Perry Belcher
A.I. Bot Summit 3 Opening Keynote - Perry Belcher
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.
 
CATALOG cáp điện Goldcup (bảng giá) 1.4.2024.PDF
CATALOG cáp điện Goldcup (bảng giá) 1.4.2024.PDFCATALOG cáp điện Goldcup (bảng giá) 1.4.2024.PDF
CATALOG cáp điện Goldcup (bảng giá) 1.4.2024.PDF
 
rishikeshgirls.in- Rishikesh call girl.pdf
rishikeshgirls.in- Rishikesh call girl.pdfrishikeshgirls.in- Rishikesh call girl.pdf
rishikeshgirls.in- Rishikesh call girl.pdf
 
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
 
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / NcrCall Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
 
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailCase study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detail
 
Marketing Management Business Plan_My Sweet Creations
Marketing Management Business Plan_My Sweet CreationsMarketing Management Business Plan_My Sweet Creations
Marketing Management Business Plan_My Sweet Creations
 

Java rmi

  • 1. JAVA RMI – INTRODUCTION RMI stands for Remote Method Invocation. It is a mechanism that allows an object residing in one systemto access/invoke anobject running on another JVM. RMI is used to build distributedapplications; it providesremote communication between Java programs. It is providedin the package java.rmi. Architecture of an RMI Application In an RMI application, we write two programs, a server programand a client program. Inside the server program, a remote object is createdand reference of that object is made available for the client . The client program requeststhe remote objectson the server and tries to invoke its methods. The following diagram shows the architecture of an RMI application. Let us now discuss the componentsof this architecture. Transport Layer − Thislayer connectsthe client and the server. It manages the existing connection and also sets up new connections. Stub − A stub is a representationof the remote object at client. It resides in the client system; it acts as a gateway for the client program. JVM residesontheserver residesontheclient usingtheregistry Skeleton− This is the object which resides on the server side. stub communicateswith this skeleton to pass request to the remote object. RRL − It is the layer which manages the referencesmade by the client to the remote object.
  • 2. Working of an RMI Application The following points summarize how an RMI application works− When the client makes a callto the remote object, it is receivedby the stub which eventually passes this request to the RRL. When the client-side RRL receivesthe request, it invokesa method called invoke of the object remoteRef. It passes the request to the RRL on the server side. The RRL on the server side passes the request to the Skeletonwhich finally invokesthe requiredobject on the server. The result is passed all the way back to the client. Marshalling and Unmarshalling Whenever a client invokesa method that acceptsparameters on a remote object, the parameters are bundled intoa message before being sent over the network. These parameters may be of primitive type or objects. Incase of primitive type, the parametersare put together and a header is attached to it. In case the parameters are objects, then they are serialized. Thisprocessis known as marshalling. At the server side, the packed parametersare unbundled and then the required method is invoked. Thisprocessis known as unmarshalling. RMI Registry RMI registry is a namespace on which all server objectsare placed. Each time the server createsan object, it registersthis object with the RMIregistry (using bind or reBind methods). These are registeredusing a unique name known as bind name. To invoke a remote object, the client needs a reference of that object. At that time, the client fetches the object from the registry using its bind name (using lookupmethod). The following illustration explains the entire process− RemoteReferenceLayer proxyontheserver Goals of RMI Following are the goals of RMI − To minimize the complexity of the application. To preserve type safety. Distributed garbage collection. Minimize the difference between working with localand remote objects. To developan RMI Application we require the followingclasses and interfaces. 1.interface 2.Implementation class 3.Server Application 4.Client Application. Defining Interface. Add.java import java.rmi.*; public interface Addextends Remote { public int sum(int a,int b) throws RemoteException; }
  • 4. ClientProgram AddClient.java importjava.rmi.*; importjava.util.*; publicclassAddClient { publicstaticvoidmain(Stringargs[]) { try { Addob=(Add)Naming.lookup(“khaja”); Scannersc=newScanner(System.in); System.out.println(“Enterthe FirstNumber“); inta=sc.nextInt(); System.out.println(“Enterthe Second Number“); intb=sc.nextInt(); intc=ob.sum(a,b); System.out.println(“sum=”+c); } catch(Exceptione) { System.out.println(e); } } } CompilationandExecutionSteps Step1:compile 4 .javafiles Step2:create stubsandskeleton(optional fromjdk1.5) >rmic AddImpl Step3:startrmiregistry >start rmiregistry Step4:startserver >start javaAddServer Step5:Run Client >javaAddClient