[Music] foreign and welcome to today's video on Java remote invocation method on Intel part first let me tell you something about Java do you know friends that Java is one of the most popular programming languages in the world and it has been used for many years in a wide range of Industries ranging from Finance to e-commerce to gaming the future scopes of java jobs is quite promising as it is widely used in the industry and demand for Java developers has always been high now before we dig dive into what exactly is Java remote invocation method do not forget to hit the Subscribe button and click the Bell icon so first we are going to start with what is Java remote method invocation moving ahead we are going to learn about stub and skeleton then we are going to discuss the requirements for distributed application and at the end we're going to conclude our session with a Hands-On so let's start with what is Java remote method invocation Java remote method invocation or RMI is in Java API that provides a mechanism to allow the invocation of methods on the remote objects RMI is basically used for building distributed applications and it enables the communication between two jvms means Java virtual machines running on different machines thus allowing the objects to interact as if they were local RMI architecture is basically based on client and server model where the client sends a request to the server which processes the request and returns a response the client and server communicates through a network using a protocol called grmp which is Java remote method protocol RMI uses stubs and skeletons to provide the communication between client and server the client holds a stub object that represents the remote object and the server holds a skeleton object that represents the local object the step object act as a proxim for remote object and a skeleton object acts as a proxy for the local object one of the advantages of using the RMI is that it allows developers to build distributed applications in such a way that it is similar to building local applications the remote objects can be accessed in the same way as local objects thus using the method calls this simplifies the development process in summary if I say remote method invocation is a powerful Java API that enables the distributed applications to communicate with each other and allowing for the development of complex and Powerful distributed systems I hope you would have got the fair idea regarding what exactly is Java remote method invocation now let's move forward and discuss about stub and skeleton in the context of java remote method invocation stub and skeletons are the two important components that facilitate the communication between client and a server in a distributed system basically if I talk about stuff it is a local object that acts as a proxy for a remote object when a client wants to invoke a method on a remote object it does so through stuff the stub in turn communicates with the remote object to perform the requested operation the stub hides the detail of the communication with the remote object from the client thus making the remote object appear as if it were a local object the client does not need to know the network location of the remote object or any details of the communication protocol instead the client simply calls a method of the step which take care of the details of the communication of the remote object stuff is generated by the RMI compiler which reads the interface of the remote object and generates a step that implements the same interface stuff is basically then compiled later on and packaged with the client application when the gland application runs it uses the stub to communicate with the remote object on the other hand if I talk about the server side a skeleton is used to receive the method invocations from the client and forwards them to the remote object the skeleton is a server side object that listens for the incoming requests from client and dispatches them to the appropriate remote object the skeleton is responsible for unmarshalling the parameters of the method call invoking the method on the remote object and thus marshaling the return value and then sending it back to the client like this step the skeleton is generated by the RMI compiler it reads the interface of the remote object generates a skeleton that implements the same interface the skeleton is then compiled and packaged with a server application when the server application runs it registers the skeleton with the RMI registry which allows the client to locate and communicate with the remote object the stubborn skeleton work together to provide a transparent communication mechanism between client and the server the client invokes the method on the stub as if it is for a local object and a step take cares of the details basically related to communication with the remote object similarly the skeleton receives the method invocations from the gland and forwards them to the remote object which processes the requests and Returns the result to the client the stubborn skeletons are generated automatically by the RMI compiler which greatly simplifies the development process in the short summary if I tell that stub and skeleton are the two key components of the Java RMI system that basically enables the communication between the client and a server basically in a distributed environment the step acts as a proxy for the remote object and hides the detail of the communication from the client while the skeleton receives the method invocations from the client and forwards them to the remote object together they provide a transparent communication mechanism that allows remote objects to be accessed as if they were a local object I hope so you would have got a fair idea regarding what exactly stubborn skeleton now let's move forward and study about requirement related to distributed application distributed applications are basically the software applications that run on a multiple machines which are connected to a network and work together to provide a single Unified Service they are becoming increasingly popular due to the scalability reliability and performance advantages over the centralized application to build the distributed application several requirements must be met the first is network connectivity distributed applications require a network that connects the different machines running the application the network must provide reliable and fast communication between different nodes in a system if I talk about security distributed applications must be secure to prevent unauthorized access and ensure data privacy authentication and authorization mechanisms must be implemented to control access to the system and its resources the third is communication protocol distributed applications require a communication protocol that enables the different nodes to communicate with each other the protocol should support message passing remote procedure calls or other forms of inter-process communication then we have a distributed computing framework a distributed computing framework is a software platform that provides necessary tools apis to build and deploy the distributed applications examples include Apache Hadoop Apache spark Anika then finally we have the load balancing load balancing is a process of Distributing the workloads across different nodes in a system to avoid overloading with anyone machine load balancing ensures that the system can handle High volumes of requests and maintain Optimal Performance then we have fault tolerance basically distributed applications must be fault tolerant meaning they can continue to function even if one or more nodes fail fault tolerance can be achieved through replication where multiple copies of data of processing are distributed across different nodes in a system and finally we have the data management distributed applications require a data management strategy that enables the efficient data storage retrieval and processing the data management strategy must address issues such as data consistency data integrity and data partioning in summary building a distributed application requires network connectivity security a communication protocol and a Distributing framework load balancing fault tolerance and data management meeting these requirements enables the creation of scalable reliable and high performance distributed system now let's move on and proceed to the Hands-On session consider this an example in which we are going to create and run the RMI application here the client application needs only two files the first one is the remote interface and the second one is the client application here in this application both Clan and server will interact with the remote interface the client application station is going to invoke methods on the proxy object and RMI sends a request to the remote jvm the return value is again sent back to the proxy object and then to the client application so first what we have to do is we are going to create the remote interface for creating the remote interface extend the remote interface and declare the remote exception with all the methods of the remote interface here we are creating a remote interface that extends the remote interface so consider this file as an Adder where we are importing java.rmi and creating an interface Adder which is extending remote and we have this method add which is taking two parameters index and into Y and it throws the remote exception then what we have to do is we have to provide the implementation of the remote interface in order to provide the implementation of the remote interface either you can extend the unicast remote object class or use the export object method of the unicast remote object class in this case we are creating a class add a remote which is extending the unicast remote object and here we are throwing a remote exception okay here we are creating a method public entered taking two parameters index and into y return X Plus y okay now the third thing what you have to do is the next step is create desktop and skeleton objects then you have to start a registry service by the RMI registry tool moving ahead what we have to do is consider this my server class okay so in this we are calling import java.rmi okay what we have else is that we are also importing java.rmi dot registry in our server class we are calling our main method and under the try and cash block we are binding our object which is basically the stub object so here we are binding the remote object by the name soon then we are going to create and run the client application at the client we are getting the stub object by the lookup method of the naming class and invoking the method on this object in this example we are running the server and a client application in the same machine so we are using the localhost if you want to access the remote object from another machine you can change the local host or the host name or the IP address where the remote object is located and in this way we complete our RMI application program based on the adder class thank you for watching this video I hope so you enjoyed our today's video on what is Java remote method invocation just a quick info guys intellect provides Java certification online training mentored by industry experts the course link of which is given in the description below