JRubyOnWebStart

Ivo Anjo edited this page Jul 18, 2016 · 1 revision

Deploying JRuby applications with Java Web Start

Table of Contents

Known Issues

Open JIRA Issues matching "Web Start or jnlp or javaws"

Samples

The samples directory distributed with JRuby has an example jnlp, http://github.com/jruby/jruby/blob/master/samples/irb-applet.html that will start the JRuby Swing IRB console as a Java Web Start application. See also http://github.com/jruby/jruby/tree/master/samples/jnlp/

Here is deployed instance: http://tim.lossen.de/2007/03/jruby/applet.html

Getting jirb.jnlp sample to work in Java 1.5

The jirb.jnlp needs to be modified to work on Java 1.5 because of the use of .. in the codebase attribute, which only works in Java 1.6.

  1. Make a symbolic link to the directory $JRUBY_HOME/lib in the samples directory (or make a copy of the lib directory).
    &nbsp; $ cd $JRUBY_HOME/samples<br/> &nbsp; $ ln -s ../lib
  2. Change the codebase attribute in the jnlp element to use a reference to the local directory.
    &nbsp; &lt;jnlp spec="1.0+" codebase="file:."&gt;
  3. Start the jnlp using javaws from the command line.
    &nbsp; $ javaws jirb.jnlp

New jnlp samples dir

The following Jira issue includes an attachment that, when extracted in samples/ adds both unsigned and signed examples that work in Java 1.5 and 1.6. It is projected to be included in JRUBY 1.1 RC2.

JAR Signing

If you're getting java.securityAccessControlException with the message access denied (java.lang.RuntimePermission accessDeclaredMembers) on startup or when running your JRuby application, then you need to sign your jar. The whole process is described here, under "Signing JAR Files with a Test Certificate".

You basically have to perform the following steps:

 keytool -genkey -keystore myKeystore -alias myself
 keytool -selfcert -alias myself -keystore myKeystore

You also need to include to following lines in your jnlp-file:

 &lt;security&gt; 
   &lt;all-permissions/&gt; 
 &lt;/security&gt;

Whenever you modify the jar, you need to do the following to update the signature:

 jarsigner -keystore myKeystore test.jar myself

Disabling the Security Manager

If you have a signed jar and the startup fails because of a java.lang.reflect.ReflectPermission, or you continue to have access denied (java.lang.RuntimePermission accessDeclaredMembers) errors, you can just disable the security manager.

Using JRuby:

 java.lang.System.setSecurityManager(nil)

Using Java:

 System.setSecurityManager(null);

Disclaimer: I'm not an expert on Java Security, so I don't know if disabling the Security Manager has unintended side effects. [User:Mstocker|Mstocker] 10:49, 30 December 2007 (PST)

See: JRUBY-1821 and JRUBY-1782.

External Links

http://almaer.com/blog/running-ruby-in-the-browser-via-script-typetextruby has some interesting stuff

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.