We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Java Web Start problem...
Page Index Toggle Pages: 1
Java Web Start problem... (Read 1303 times)
Java Web Start problem...
Sep 27th, 2006, 6:22pm
 
Hi All:
I’m trying to create a processing sketch that will run from Java Web Start instead of as an applet or an application.  Sorry for the long post, I wanted to get all the details captured.
Any/all help is greatly appreciated!
THANXS
amb

The problem:
Trying to launch via Web Server or from Windows Explorer behave the same…The Java Web Start splash screen comes up for about second and then the program exits.  I configured the java console to appear [Control Panel, Java, Java Tab, Advanced, Java Console, show Console].  Now the console flashes up for a second and it exits too.  It’s too quick to see anything.
I did verify that Sun’s SwingSet2.jar & SwingSet2.jnlp work fine on my system through the web server and from Windows Explorer.

My setup:
I’m on a PC running Windows XP Professional OS, IE Version 6.0, Processing 0115 Beta, Sun Java 2 Platform Standard Edition Version 1.5.0 (build 1.5.0_08-b03), and Apache Version 2.2 web server.
I used the “Button” sketch [Examples, GUI, Button.pde] as my test case.
I added a main method to this sketch:
    static public void main(String args[]) {
         PApplet.main(new String[] { "Button" });
    }  // end method main…
Next, I saved and exported the sketch as an Applet.  
I verified that the “Button.jar” file that I just created can execute with a double click from Windows explorer and from a command prompt using the command “java –jar Button.jar”
I configured Apache to associate the appropriate MIME type by adding the following line to the “.mime.types” configuration file [Yes, I did restart the service after the change]:

application/x-java-jnlp-file JNLP
I copied the Button.jar file created above to my Apache’s “htdoc” folder and created a JNLP file by modifying Sun’s SwingSet2.JNLP:
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="0.2 1.0" codebase="http:// my_host_name_here" href="Button.jnlp">
       <information>
          <title>SwingSet2 App</title>
          <vendor>Sun Microsystems, Inc.</vendor>
          <homepage      href="http://java.sun.com/products/javawebstart/demos.html"/>
          <description>SwingSet2 Demo Description</description>
          <description kind="short">SwingSet2 Demo Short Description</description>
          <offline-allowed/>
       </information>
       <resources>
          <j2se version="1.3+"      href="http://java.sun.com/products/autodl/j2se"/>
          <j2se version="1.3+"/>
          <jar href="Button.jar" main="true" download="eager"/>
       </resources>
       <application-desc main-class="Button"/>
    </jnlp>  
Re: Java Web Start problem...SOLVED
Reply #1 - Sep 28th, 2006, 1:49pm
 
Hi fry:
Thanks for moving to right location!

Ok…Thanks to a very smart co-worker, we’ve got this figured out!
The problem is security related…Processing jar files must be signed to run via Java Web Start!
He figured out how to turn on Error Tracing and Error Logging.  [in my configuration, it is under Control Panel, Java Control Panel, Advanced tab, Debugging, check the two appropriate boxes]
Please see the following URL for more details on debugging Java Web Start stuff:
http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/troubleshooting.03.06.html

Running my “Button.jnlp” test generates the following error messages:
java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
           at java.security.AccessControlContext.checkPermission(Unknown Source)
           at java.security.AccessController.checkPermission(Unknown Source)
           at java.lang.SecurityManager.checkPermission(Unknown Source)
           at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
           at java.lang.System.getProperty(Unknown Source)
           at processing.core.PApplet.main(PApplet.java:5952)
           at Button.main(Button.java:106)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at com.sun.javaws.Launcher.executeApplication(Unknown Source)
           at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
           at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
           at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
           at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
           at com.sun.javaws.Launcher.run(Unknown Source)
           at java.lang.Thread.run(Unknown Source)

Since processing tries to access the “user.dir”, it needs to be signed!
We found more info on signing jar files at:
http://wiki.jmol.org/index.php/Java_Web_Start

Finally, here is the step-by-step to get a Processing sketch running via Java Web Start:
1.Open the Button example sketch in Processing IDE, save as “ButtonJWS”
2.Add the following main method:
static public void main(String args[]) {
  PApplet.main(new String[] { "ButtonJWS" });
} // end method main...
3.Select “Save” and then “Export”
4.Copy the file “ButtonJWS.jar” to a folder that your web server can access
5.Create a “ButtonJWS.jnlp” file in the same directory containing the following lines:
<?xml version="1.0" encoding="utf-8"?>
<jnlp
 spec="1.0+"
 codebase="http://www.whatever.com"
 href="ButtonJWS.jnlp">
 <information>
   <title>Testing Processing via Java Web Start</title>
   <vendor>processing.org</vendor>
   <homepage href="http://www.processing.org"/>
   <description>Testing Processing via Java Web Start</description>
   <description kind="short">Processing is an open source programming language and environment for people who want to program images, animation, and sound.</description>
   <offline-allowed/>
 </information>
 <security>
   <all-permissions/>
 </security>
 <resources>
   <j2se version="1.4+"/>
   <jar href="ButtonJWS.jar"/>
 </resources>
 <application-desc main-class="ButtonJWS"/>
</jnlp>
6.Create a new key in a new keystore with the following command:
keytool -genkey -keystore myKeystore -alias myself
7.Create a self-signed test certificate as follows:
keytool -selfcert -alias myself -keystore myKeystore
8.Sign the Jar file as follows:
jarsigner -keystore myKeystore ButtonJWS.jar myself
9.Double click on the JNLP file you created, accept the security certificate prompt, and watch the sketch run
10.Create a simple HTML file to launch your sketch:
<HTML>
<A HREF="http://www.whatever.com/ButtonJWS.jnlp"> click here to test processing via web start!</A>
</HTML>
11.Load that page in your favorite web browser, click the link, and watch the sketch run
12.The End.

Re: Java Web Start problem...
Reply #2 - Sep 28th, 2006, 2:10pm
 
interesting, thanks for posting.. for 0116, i've just altered the main to catch the security exception, so perhaps that will avoid the issue. the problem is that PApplet was assuming that it was running locally if it was being run from its main(). not sure if that will fix all the web start issues, but we'll see.
Page Index Toggle Pages: 1