{"id":26747,"date":"2021-04-30T23:10:08","date_gmt":"2021-05-01T03:10:08","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/rmi-example-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-j2\/"},"modified":"2021-04-30T23:10:08","modified_gmt":"2021-05-01T03:10:08","slug":"rmi-example-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-j2","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=26747","title":{"rendered":"# 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"},"content":{"rendered":"<pre>\n# RMI Example - Numerical Integration, a more realistic RMI example that sends an evaluatable object (function) from a client to a server for numerical integration. \n\nIntegral.java  Performs actual numerical integration of the function (evaluatable object).\n\n\/** A class to calculate summations and numeric integrals. The\n *  integral is calculated according to the midpoint rule.\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 Integral {\n  \/** Returns the sum of f(x) from x=start to x=stop, where the\n   *  function f is defined by the evaluate method of the\n   *  Evaluatable object.\n   *\/\n\n  public static double sum(double start, double stop,\n                           double stepSize,\n                           Evaluatable evalObj) {\n    double sum = 0.0, current = start;\n    while (current  0) ? args[0] : &quot;localhost&quot;;\n      RemoteIntegral remoteIntegral =\n        (RemoteIntegral)Naming.lookup(&quot;rmi:\/\/&quot; + host +\n                                      &quot;\/RemoteIntegral&quot;);\n      for(int steps=10; steps 0) ? args[0] : &quot;localhost&quot;;\n      RemoteIntegral remoteIntegral =\n        (RemoteIntegral)Naming.lookup(&quot;rmi:\/\/&quot; + host +\n                                      &quot;\/RemoteIntegral&quot;);\n      for(int steps=10; steps&lt; =10000; steps*=10) {\n        System.out.println\n          (&quot;Approximated with &quot; + steps + &quot; steps:&quot; +\n           &quot;n  Integral from 0 to pi of sin(x)=&quot; +\n           remoteIntegral.integrate(0.0, Math.PI,\n                                    steps, new Sin()) +\n           &quot;n  Integral from pi\/2 to pi of cos(x)=&quot; +\n           remoteIntegral.integrate(Math.PI\/2.0, Math.PI,\n                                    steps, new Cos()) +\n           &quot;n  Integral from 0 to 5 of x^2=&quot; +\n           remoteIntegral.integrate(0.0, 5.0, steps,\n                                    new Quadratic()));\n      }\n      System.out.println\n        (&quot;`Correct&#039; answer using Math library:&quot; +\n         &quot;n  Integral from 0 to pi of sin(x)=&quot; +\n         (-Math.cos(Math.PI) - -Math.cos(0.0)) +\n         &quot;n  Integral from pi\/2 to pi of cos(x)=&quot; +\n         (Math.sin(Math.PI) - Math.sin(Math.PI\/2.0)) +\n         &quot;n  Integral from 0 to 5 of x^2=&quot; +\n         (Math.pow(5.0, 3.0) \/ 3.0));\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\nrmiclient.policy  Policy file for the client. Grants permissions for the client to connect to the RMI server and Web server. \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\ngrant {\n  \/\/ rmihost - RMI registry and the server\n  \/\/ webhost - HTTP server for stub classes\n  permission java.net.SocketPermission \n    &quot;rmihost:1024-65535&quot;, &quot;connect&quot;;\n  permission java.net.SocketPermission \n    &quot;webhost:80&quot;, &quot;connect&quot;;\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=10239<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; 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 according to the midpoint rule. &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=26747\">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-26747","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":10208,"url":"http:\/\/bangla.sitestree.com\/?p=10208","url_meta":{"origin":26747,"position":0},"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":10206,"url":"http:\/\/bangla.sitestree.com\/?p=10206","url_meta":{"origin":26747,"position":1},"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":26745,"url":"http:\/\/bangla.sitestree.com\/?p=26745","url_meta":{"origin":26747,"position":2},"title":"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","author":"Author-Check- Article-or-Video","date":"April 30, 2021","format":false,"excerpt":"RMI Example - 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\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":26747,"position":3},"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":[]},{"id":67690,"url":"http:\/\/bangla.sitestree.com\/?p=67690","url_meta":{"origin":26747,"position":4},"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":26747,"position":5},"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":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26747","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=26747"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26747\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26747"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}