浙江省高等学校教师教育理论培训

微信搜索“教师资格证岗前培训”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

JRuby: Wiki: JRubyOnWebStart — Project Kenai

Deploying JRuby applications with Java Web Start

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).
      $ cd $JRUBY_HOME/samples
      $ ln -s ../lib
  2. Change the codebase attribute in the jnlp element to use a reference to the local directory.
      <jnlp spec="1.0+" codebase="file:.">
  3. Start the jnlp using javaws from the command line.
      $ 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:

 <security>
   <all-permissions/>
 </security>

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

posted on 2012-02-28 23:19  lexus  阅读(281)  评论(0编辑  收藏  举报