{"id":26745,"date":"2021-04-30T23:10:07","date_gmt":"2021-05-01T03:10:07","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/rmi-example-message-illustrates-retrieving-a-message-from-an-object-located-on-a-remote-server-requires-the-following-classes-programming-code-examples-java-j2ee-j2me-network-programming\/"},"modified":"2021-04-30T23:10:07","modified_gmt":"2021-05-01T03:10:07","slug":"rmi-example-message-illustrates-retrieving-a-message-from-an-object-located-on-a-remote-server-requires-the-following-classes-programming-code-examples-java-j2ee-j2me-network-programming","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=26745","title":{"rendered":"RMI Example &#8211; Message, illustrates retrieving a message from an object located on a remote server. Requires the following classes: #Programming Code Examples #Java\/J2EE\/J2ME #Network Programming"},"content":{"rendered":"<pre>\nRMI Example - Message, illustrates retrieving a message from an object located on a remote server. Requires the following classes: \n\nRem.java  Establishes which methods the client can access in the remote object. \n\n\n\n\n\nimport java.rmi.*;\n\n\/** The RMI client will use this interface directly. The RMI\n *  server will make a real remote object that implements this,\n *  then register an instance of it with some URL.\n *\n *  Taken from Core Web Programming from\n *  Prentice Hall and Sun Microsystems Press,\n *  .\n *  &copy; 2001 Marty Hall and Larry Brown;\n *  may be freely used or adapted.\n *\/\n\npublic interface Rem extends Remote {\n  public String getMessage() throws RemoteException;\n}\n\n\nRemClient.java  The client application which communicates to the remote object and retrieves the message. \n\nimport java.rmi.*; \/\/ For Naming, RemoteException, etc.\nimport java.net.*; \/\/ For MalformedURLException\nimport java.io.*;  \/\/ For Serializable interface\n\n\/** Get a Rem object from the specified remote host.\n *  Use its methods as though it were a local object.\n *\n *  Taken from Core Web Programming from\n *  Prentice Hall and Sun Microsystems Press,\n *  .\n *  &copy; 2001 Marty Hall and Larry Brown;\n *  may be freely used or adapted.\n *\/\n\npublic class RemClient {\n  public static void main(String[] args) {\n    try {\n      String host =\n        (args.length &gt; 0) ? args[0] : &quot;localhost&quot;;\n      \/\/ Get the remote object and store it in remObject:\n      Rem remObject =\n        (Rem)Naming.lookup(&quot;rmi:\/\/&quot; + host + &quot;\/Rem&quot;);\n      \/\/ Call methods in remObject:\n      System.out.println(remObject.getMessage());\n    } catch(RemoteException re) {\n      System.out.println(&quot;RemoteException: &quot; + re);\n    } catch(NotBoundException nbe) {\n      System.out.println(&quot;NotBoundException: &quot; + nbe);\n    } catch(MalformedURLException mfe) {\n      System.out.println(&quot;MalformedURLException: &quot; + mfe);\n    }\n  }\n}\n\n\nRemImpl.java  The concrete, remote object that implements the methods in Rem.java. \n\nimport java.rmi.*;\nimport java.rmi.server.UnicastRemoteObject;\n\n\/** This is the actual implementation of Rem that the RMI\n *  server uses. The server builds an instance of this, then\n *  registers it with a URL. The client accesses the URL and\n *  binds the result to a Rem (not a RemImpl; it doesn't\n *  have this).\n *\n *  Taken from Core Web Programming from\n *  Prentice Hall and Sun Microsystems Press,\n *  .\n *  &copy; 2001 Marty Hall and Larry Brown;\n *  may be freely used or adapted.\n *\/\n\npublic class RemImpl extends UnicastRemoteObject\n                     implements Rem {\n  public RemImpl() throws RemoteException {}\n\n  public String getMessage() throws RemoteException {\n    return(&quot;Here is a remote message.&quot;);\n  }\n}\n\n\nRemServer.java  Creates an instance of RemImpl on the remote server and binds the object in the registry for lookup by the client. \n\nimport java.rmi.*;\nimport java.net.*;\n\n\/** The server creates a RemImpl (which implements the Rem\n *  interface), then registers it with the URL Rem, where\n *  clients can access it.\n *\n *  Taken from Core Web Programming from\n *  Prentice Hall and Sun Microsystems Press,\n *  .\n *  &copy; 2001 Marty Hall and Larry Brown;\n *  may be freely used or adapted.\n *\/\n\npublic class RemServer {\n  public static void main(String[] args) {\n    try {\n      RemImpl localObject = new RemImpl();\n      Naming.rebind(&quot;rmi:\/\/\/Rem&quot;, localObject);\n    } catch(RemoteException re) {\n      System.out.println(&quot;RemoteException: &quot; + re);\n    } catch(MalformedURLException mfe) {\n      System.out.println(&quot;MalformedURLException: &quot; + mfe);\n    }\n  }\n}\n\n\n<\/pre>\n<p>Note: Brought from our old site: http:\/\/www.salearningschool.com\/example_codes\/ on Jan 2nd, 2017 From: http:\/\/sitestree.com\/?p=10238<br \/> Categories:Programming Code Examples, Java\/J2EE\/J2ME, Network Programming<br \/>Tags:Java\/J2EE\/J2MENetwork Programming<br \/> Post Data:2017-01-02 16:04:28<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>RMI Example &#8211; Message, illustrates retrieving a message from an object located on a remote server. Requires the following classes: Rem.java Establishes which methods the client can access in the remote object. import java.rmi.*; \/** The RMI client will use this interface directly. The RMI * server will make a real remote object that implements &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=26745\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-26745","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":10206,"url":"http:\/\/bangla.sitestree.com\/?p=10206","url_meta":{"origin":26745,"position":0},"title":"RMI Example &#8211; Message, illustrates retrieving a message from an object located on a remote server. Requires the following classes","author":"","date":"August 25, 2015","format":false,"excerpt":"Rem.java\u00a0 Establishes which methods the client can access in the remote object. import java.rmi.*; \/** The RMI client will use this interface directly. The RMI \u00a0*\u00a0 server will make a real remote object that implements this, \u00a0*\u00a0 then register an instance of it with some URL. \u00a0* \u00a0*\u00a0 Taken from\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10208,"url":"http:\/\/bangla.sitestree.com\/?p=10208","url_meta":{"origin":26745,"position":1},"title":"RMI Example &#8211; Numerical Integration, a more realistic RMI example that sends an evaluatable object (function) from a client to a server for numerical integration.","author":"","date":"August 25, 2015","format":false,"excerpt":"Integral.java\u00a0 Performs actual numerical integration of the function (evaluatable object). \/** A class to calculate summations and numeric integrals. The \u00a0*\u00a0 integral is calculated according to the midpoint rule. \u00a0* \u00a0*\u00a0 Taken from Core Web Programming from \u00a0*\u00a0 Prentice Hall and Sun Microsystems Press, \u00a0*\u00a0 . \u00a0*\u00a0 \u00a9 2001 Marty\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26747,"url":"http:\/\/bangla.sitestree.com\/?p=26747","url_meta":{"origin":26745,"position":2},"title":"# RMI Example &#8211; Numerical Integration, a more realistic RMI example that sends an evaluatable object (function) from a client to a server for numerical integration. #Programming Code Examples #Java\/J2EE\/J2ME #Network Programming","author":"Author-Check- Article-or-Video","date":"April 30, 2021","format":false,"excerpt":"# RMI Example - Numerical Integration, a more realistic RMI example that sends an evaluatable object (function) from a client to a server for numerical integration. Integral.java Performs actual numerical integration of the function (evaluatable object). \/** A class to calculate summations and numeric integrals. The * integral is calculated\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":67690,"url":"http:\/\/bangla.sitestree.com\/?p=67690","url_meta":{"origin":26745,"position":3},"title":"Basic Java But Essential Knowledge for exams like SCJA, or to the project managers new to Java technologies #Computer Game Design #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 27, 2021","format":false,"excerpt":"By definition an enumerated type is a finite set of symbolic literals In Java an enumerated type is represented as first-class object. Enumerated type literals are allowed in case statements. The literals of an enumerated type may be of any valid Java identifier An interface may NOT contain any concrete\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":66324,"url":"http:\/\/bangla.sitestree.com\/?p=66324","url_meta":{"origin":26745,"position":4},"title":"EJB Overview: EJB in a nutshell #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 18, 2021","format":false,"excerpt":"Objects provide encapsulation\/re-usability at the class level. A component can be comprised of multiple objects Component = logical groups of classes = distributed objects = business objects A component can be developed to address a specific enterprise applications. Hence, components can provide significant encapsulation\/re-usability in the partitioned enterprise problems. Component\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65920,"url":"http:\/\/bangla.sitestree.com\/?p=65920","url_meta":{"origin":26745,"position":5},"title":"What is Spring Framework? What does it mean to J2EE developers #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 17, 2021","format":false,"excerpt":"What is Spring Framework? What does it mean to J2EE developers? Spring is a light-weight framework, very often referred as an alternative\/competitor to EJB, for the development of enterprise-type applications. Spring provides many features such as declarative transaction management, access to remote logic using RMI or web services, mailing facilities\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26745"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26745\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26745"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}