{"id":5710,"date":"2016-09-14T14:11:10","date_gmt":"2016-09-14T19:11:10","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=5710"},"modified":"2016-09-14T14:11:10","modified_gmt":"2016-09-14T19:11:10","slug":"jnlp-example","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2016\/09\/14\/jnlp-example\/","title":{"rendered":"JNLP Example"},"content":{"rendered":"<p>Java Web Start is the technology that allows a user to run java from their local device.  The software that is run is loaded from a server via a directive in a JNLP file on the server.  It is downloaded to the client.<\/p>\n<p>Test class&#8230;<\/p>\n<pre>\r\nimport javax.swing.*;\r\nimport java.sql.*;\r\n\r\npublic class JNLPTest extends JFrame {\r\n\r\n  private static final long serialVersionUID = 4968624166243565348L;\r\n\r\n  private static JTextArea label = new JTextArea();\r\n\r\n  public JNLPTest() {\r\n    super(\"JNLP Test\");\r\n    this.setSize(700, 400);\r\n    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n    this.setLayout(null);\r\n  }\r\n\r\n  public void addButtons() {\r\n\tlabel.setSize(400, 180);\r\n\tlabel.setLocation(160, 100);\r\n\tthis.getContentPane().add(label);\r\n  }\r\n\r\n  public static void main(String[] args) throws Exception {\r\n\ttry {\r\n  \t  Class.forName(\"oracle.jdbc.driver.OracleDriver\");\r\n\t  Connection conn = DriverManager.getConnection(\"jdbc:oracle:thin:\" + args[0] + \"\/\" + args[1] + \"@\" + args[2] + \":\" + args[3] + \"\/\" + args[4]);\r\n\t  ResultSet rst = conn.createStatement().executeQuery(\"select distinct machine from gv$session\");\r\n\t  StringBuffer sb = new StringBuffer();\r\n\t  while (rst.next()) {\r\n\t\tsb.append(rst.getString(1) + '\\n');\r\n\t  }\r\n\t  label.setText(sb.toString());\r\n    }\r\n    catch (Exception e) {\r\n\t  label.setText(e.getMessage());\r\n\t  e.printStackTrace();\r\n\t}\r\n\tJNLPTest exp = new JNLPTest();\r\n\texp.addButtons();\r\n\texp.setVisible(true);\r\n  }\r\n}\r\n<\/pre>\n<p>JNLP file&#8230;<\/p>\n<pre>\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<jnlp spec=\"1.0+\" codebase=\"http:\/\/localhost:8080\/\" href=\"JNLPTest.jnlp\">\r\n\r\n  <information>\r\n    <title>JNLP Test<\/title>\r\n    <vendor>EXPRESS<\/vendor>\r\n    <homepage href=\"http:\/\/localhost:8080\/\" \/>\r\n    <description>JNLP Test<\/description>\r\n  <\/information>\r\n\r\n  <security>\r\n    <all-permissions\/>\r\n  <\/security>\r\n\r\n  <resources>\r\n    <j2se version=\"1.7*\" \/>\r\n    <jar href=\"JNLPTest.jar\" \/>\r\n    <jar href=\"ojdbc6.jar\" \/>\r\n  <\/resources>\r\n\r\n  <application-desc main-class=\"JNLPTest\">\r\n    <argument>username<\/argument>\r\n    <argument>password<\/argument>\r\n    <argument>dbhost<\/argument>\r\n    <argument>1521<\/argument>\r\n    <argument>servicename.domain<\/argument>\r\n  <\/application-desc>\r\n<\/jnlp>\r\n<\/pre>\n<p>You can build the java class above, as well as sign it, with what is below..<\/p>\n<pre>\r\nc:\\Users\\showard\\Downloads>del testkeys\r\n\r\nc:\\Users\\showard\\Downloads>javac JNLPTest.java\r\n\r\nc:\\Users\\showard\\Downloads>jar -cvf JNLPTest.jar JNLPTest.class\r\nadded manifest\r\nadding: JNLPTest.class(in = 2290) (out= 1309)(deflated 42%)\r\n\r\nc:\\Users\\showard\\Downloads>keytool -genkey -keystore testkeys -alias welcome\r\nEnter keystore password:\r\nRe-enter new password:\r\nWhat is your first and last name?\r\n  [Unknown]:\r\nWhat is the name of your organizational unit?\r\n  [Unknown]:\r\nWhat is the name of your organization?\r\n  [Unknown]:\r\nWhat is the name of your City or Locality?\r\n  [Unknown]:\r\nWhat is the name of your State or Province?\r\n  [Unknown]:\r\nWhat is the two-letter country code for this unit?\r\n  [Unknown]:\r\nIs CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct?\r\n  [no]:  yes\r\n\r\nEnter key password for <welcome>\r\n        (RETURN if same as keystore password):\r\n\r\nc:\\Users\\showard\\Downloads>jarsigner -keystore testkeys JNLPTest.jar welcome\r\nEnter Passphrase for keystore:\r\njar signed.\r\n\r\nWarning:\r\nThe signer certificate will expire within six months.\r\nNo -tsa or -tsacert is provided and this jar is not timestamped. Without a times\r\ntamp, users may not be able to validate this jar after the signer certificate's\r\nexpiration date (2016-12-13) or after any future revocation date.\r\n\r\nc:\\Users\\showard\\Downloads>jarsigner -keystore testkeys ojdbc6.jar welcome\r\nEnter Passphrase for keystore:\r\njar signed.\r\n\r\nWarning:\r\nThe signer certificate will expire within six months.\r\nNo -tsa or -tsacert is provided and this jar is not timestamped. Without a times\r\ntamp, users may not be able to validate this jar after the signer certificate's\r\nexpiration date (2016-12-13) or after any future revocation date.\r\n\r\nc:\\Users\\showard\\Downloads>\r\n<\/pre>\n<p>Deploy the JNLPTest.jar and ojdbc6.jar (available for download on the internet), as well as the JNLP file to your application server.  Request the JNLP file in your browser, and if you have java properly configured in the browser, it should execute the class and print the list of distinct machines logged into the Oracle database you configure in the JNLP file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java Web Start is the technology that allows a user to run java from their local device. The software that is run is loaded from a server via a directive in a JNLP file on the server. It is downloaded&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2016\/09\/14\/jnlp-example\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[48,7],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5710"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=5710"}],"version-history":[{"count":4,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5710\/revisions"}],"predecessor-version":[{"id":5715,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5710\/revisions\/5715"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=5710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=5710"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=5710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}