`
defrag_sly
  • 浏览: 126123 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

将Eclipse RCP与Java Web Start结合发布为web应用(1)

阅读更多
将Eclipse RCP与Java Web Start结合发布为web应用,可以替代原有的java Applet提供一个更易扩展,更新,组件间耦合度更低,功能更强的应用程序。可以为web上的特定应用提供解决方案。B/S结构的应用程序客户端不再局限于浏览器。
1、 创建RCP工程:
    使用插件工程创建向导,创建一个插件工程,名为org.rufus.javaeye.jws.eclipse。
    选择Rich Client Application为yes。
Templates选择页面,选择一个例子,view或者Hello RCP。
2、 为RCP工程创建feature:
    创建一个feature-project,名为org.rufus.javaeye.jws.eclipse.feature。
    打开feature.xml:
    plug-ins标签,加入工程:org.rufus.javaeye.jws.eclipse。
    included features标签,加入feature:org.eclipse.rcp。
    build.properties标签,输入“root=webroot”。
    在feature工程下创建目录webroot。
3、 创建数字签名:
    由于java安全控制的关系,所有下载到客户端的jar包都应该具有数字签名。
    Java命令:keytool -genkey -keystore myKeystore -alias mykeystore。
    将startup.jar用数字签名(如果使用的是eclipse3.3,请拷贝3.2根目录下startup.jar)
    Java命令:jarsigner -keystore myKeystore startup.jar mykeystore
    将过签名的startup.jar拷贝到webroot目录下。
4、 创建jnlp文件:
    在webroot目录下创建jnlp文件,取名为test.jnlp
文件内容:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://192.168.0.190:8888/mysite(需要修改为http://serverIP:port/appName" href="test.jnlp">
    <information>
        <title>Test</title>
        <vendor>sly</vendor>
        <icon kind="splash" href="splash.gif"/>
        <offline-allowed/>
    </information>
    <security>
        <all-permissions/>
    </security>
    <application-desc main-class="org.eclipse.core.launcher.WebStartMain">
        <argument>-nosplash </argument>
    </application-desc>
    <resources>
        <j2se version="1.4+" />
        <jar href="startup.jar"/>
        <extension name="the feature" href="features/org.rufus.javaeye.jws.eclipse.feature_1.0.0.jnlp"/>
	
	  <property name="eclipse.application" value="org.rufus.javaeye.jws.eclipse.application"/>
	  <!--        <property name="eclipse.product" value="org.rufus.javaeye.jws.eclipse.product"/>-->

    </resources>
    
    <resources os="Windows">
        <property name="osgi.instance.area" value="@user.home/Application Data/test"/>
        <property name="osgi.configuration.area" value="@user.home/Application Data/test"/>
    </resources>
</jnlp>

5、 导出RCP工程:
    打开feature.xml,
    overview标签,选择export wizard。
    Destination标签,选择一个导出的路径。
    Options标签,选择package as individual jar archives(required for JNLP and update site)。
    Jar signing标签,选择刚刚创建的key store,输入别名(alias),密码。
    Java Web Start标签,输入站点的ip和地址(http://serverIP:port/appName),jre版 本:1.4+。
    Finish,将导出的文件拷贝到站点的根目录下。
6、 测试:启动服务器,在站点根目录下,双击运行test.jnlp。
7、 以上在win2003,jdk1.5,eclipse3.3测试通过。

===20090519===
此博发布半年后的某天,IBM的eclipse开发者group有了同样功能的一篇,地址如下,留作参考。
http://www.ibm.com/developerworks/cn/opensource/tutorials/os-eclipse-jws/index.html
5
0
分享到:
评论
18 楼 defrag_sly 2011-07-01  
FS42 写道
运行text.jnlp后 jws看上去已经启动了 但没有任何显示反应 这是什么原因呢?

看看log吧.可能启动时出错了.
17 楼 FS42 2011-06-30  
运行text.jnlp后 jws看上去已经启动了 但没有任何显示反应 这是什么原因呢?
16 楼 defrag_sly 2011-06-14  
zyfromcq 写道
我在运行的时候前台突然就没反应了,但日志里面包下列错误,请问这是什么情况?

!SESSION Mon Jun 13 11:00:26 CST 2011 ------------------------------------------
!ENTRY org.eclipse.core.launcher 4 0 2011-06-13 11:00:26.207
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.io.IOException: Unable to initialize osgi.frameworkClassPath
at org.eclipse.core.launcher.Main.addBaseJars(Main.java:571)
at org.eclipse.core.launcher.Main.getDevPath(Main.java:470)
at org.eclipse.core.launcher.Main.getBootPath(Main.java:650)
at org.eclipse.core.launcher.WebStartMain.getBootPath(WebStartMain.java:72)
at org.eclipse.core.launcher.Main.basicRun(Main.java:274)
at org.eclipse.core.launcher.WebStartMain.basicRun(WebStartMain.java:63)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.WebStartMain.main(WebStartMain.java:42)
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.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


这个例子是eclipse3.3,看看你的版本,还有feature下面引用的包对不对。
15 楼 zyfromcq 2011-06-13  
我在运行的时候前台突然就没反应了,但日志里面包下列错误,请问这是什么情况?

!SESSION Mon Jun 13 11:00:26 CST 2011 ------------------------------------------
!ENTRY org.eclipse.core.launcher 4 0 2011-06-13 11:00:26.207
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.io.IOException: Unable to initialize osgi.frameworkClassPath
at org.eclipse.core.launcher.Main.addBaseJars(Main.java:571)
at org.eclipse.core.launcher.Main.getDevPath(Main.java:470)
at org.eclipse.core.launcher.Main.getBootPath(Main.java:650)
at org.eclipse.core.launcher.WebStartMain.getBootPath(WebStartMain.java:72)
at org.eclipse.core.launcher.Main.basicRun(Main.java:274)
at org.eclipse.core.launcher.WebStartMain.basicRun(WebStartMain.java:63)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.WebStartMain.main(WebStartMain.java:42)
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.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

14 楼 shijiyu1984 2010-01-27  
我双击test.jnlp文件怎么不能运行呢?
13 楼 defrag_sly 2009-05-07  
zhaofangtao 写道

hi,我的程序通过test.jnlp可以启动了。

但是现在我发布在本地,codebase="file:/E:/eclipse/。。。

那我如果用外部地址,用户在客户端访问服务器启动,比如: codebase="http://192.168.0.190:8888/。。。。

那我该怎么发布呢
那是不是还需要tomcat一样的web服务器呢


是的,像普通的jnlp一样就可以了。
12 楼 zhaofangtao 2009-05-06  
hi,我的程序通过test.jnlp可以启动了。

但是现在我发布在本地,codebase="file:/E:/eclipse/。。。

那我如果用外部地址,用户在客户端访问服务器启动,比如: codebase="http://192.168.0.190:8888/。。。。

那我该怎么发布呢
那是不是还需要tomcat一样的web服务器呢
11 楼 zhaofangtao 2009-05-06  
找到地方了,解决了,谢谢,哈哈,占了你这么大地方
10 楼 zhaofangtao 2009-05-06  
在配置文件里面是没有org.eclipse.swt.wpf 的

<resources>
<jar href="plugins/com.ibm.icu_3.8.1.v20080530.jar"/>
<jar href="plugins/org.eclipse.core.commands_3.4.0.I20080509-2000.jar"/>
<jar href="plugins/org.eclipse.core.databinding_1.1.1.M20080827-0800b.jar"/>
<jar href="plugins/org.eclipse.core.databinding.beans_1.1.1.M20080827-0800a.jar"/>
<jar href="plugins/org.eclipse.core.jobs_3.4.1.R34x_v20081128.jar"/>
<jar href="plugins/org.eclipse.core.expressions_3.4.1.r342_v20081203-0800.jar"/>
<jar href="plugins/org.eclipse.core.runtime_3.4.0.v20080512.jar"/>
<jar href="plugins/org.eclipse.core.runtime.compatibility.auth_3.2.100.v20070502.jar"/>
<jar href="plugins/org.eclipse.osgi_3.4.3.R34x_v20081215-1030.jar"/>
<jar href="plugins/org.eclipse.help_3.3.102.v20081014_34x.jar"/>
<jar href="plugins/org.eclipse.swt_3.4.2.v3452b.jar"/>
<jar href="plugins/org.eclipse.jface_3.4.2.M20090107-0800.jar"/>
<jar href="plugins/org.eclipse.jface.databinding_1.2.1.M20080827-0800a.jar"/>
<jar href="plugins/org.eclipse.ui_3.4.2.M20090204-0800.jar"/>
<jar href="plugins/org.eclipse.ui.workbench_3.4.2.M20090127-1700.jar"/>
</resources>

但是异常信息怎么给提示出来了,纳闷
9 楼 zhaofangtao 2009-05-06  
hi,谢谢你的回复

这个问题后来解决了,我将jre换成jdk后,忘记了设环境变量。谢谢你。
我用的是3.2,后来因为3.2的一个小bug,启动后总是找不到应用程序版本,也找到原因了,感觉不好改,我就下载了3.4再做你这个例子。
现在出现了新问题。启动test.jnlp下载完后,org.eclipse.swt.wpf加载不上,我不清楚为什么会提示这个插件,。也没找到。麻烦再帮我看看怎么回事

java.io.FileNotFoundException: E:\eclipse\Workspace\org.rufus.javaeye.jws.eclipse.feature\webroot\plugins\org.eclipse.swt.wpf.win32.x86_3.4.1.v3452b.jar (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
at com.sun.deploy.net.BasicHttpRequest.doGetRequest(Unknown Source)
at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
at com.sun.javaws.LaunchDownload.downloadJarFiles(Unknown Source)
at com.sun.javaws.LaunchDownload.downloadEagerorAll(Unknown Source)
at com.sun.javaws.Launcher.downloadResources(Unknown Source)
at com.sun.javaws.Launcher.prepareLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

8 楼 defrag_sly 2009-05-06  
zhaofangtao 写道

hi,兄弟, 我看了你的关于用java web start发布应用程序的帖子,我就照做,结果在eclipse中打包签名的时候,提示Execute failed: java.io.IOException: Cannot run program "jarsigner.exe"这个异常, 我已经反复检查过了,我已经把jre换成jdk了。还有keystore这些都做了,但是一直签名失败。我想请教一下是怎么回事,真诚期待你的帮助。




你好 :zhaofangtao

有关jar sign的地方请你检查一下:
3、 创建数字签名:
    由于java安全控制的关系,所有下载到客户端的jar包都应该具有数字签名。
    Java命令:keytool -genkey -keystore myKeystore -alias mykeystore。
    将startup.jar用数字签名(如果使用的是eclipse3.3,请拷贝3.2根目录下startup.jar)
    Java命令:jarsigner -keystore myKeystore startup.jar mykeystore
    将过签名的startup.jar拷贝到webroot目录下。
5、 导出RCP工程:
Options标签,选择package as individual jar archives(required for JNLP and update site)。
Jar signing标签,选择刚刚创建的key store,输入别名(alias),密码。

如果以上都确认了,可以再确认下系统path是否设置正确。
印象中好像出现过你说的这个异常,不过时间太久了。已经忘记怎么解决的了,很抱歉。
7 楼 zhaofangtao 2009-05-05  
hi,兄弟, 我看了你的关于用java web start发布应用程序的帖子,我就照做,结果在eclipse中打包签名的时候,提示Execute failed: java.io.IOException: Cannot run program "jarsigner.exe"这个异常, 我已经反复检查过了,我已经把jre换成jdk了。还有keystore这些都做了,但是一直签名失败。我想请教一下是怎么回事,真诚期待你的帮助。

6 楼 defrag_sly 2008-12-11  
kelvinlaw 写道

Thanks for you reply.I try so hard in building RCP + Webstart. But webstart console closed immediately after launching.could you please send me your eclipse RCP projects by mail? so that I can trace what is wrong.Email: kelvin382@gmail.com

附件中便是我的测试工程了。JWS的控制台是可以设置为不关闭的。具体设置忘记了。你可以到控制面板看看。或者google一下。
5 楼 kelvinlaw 2008-12-10  
Thanks for you reply.

I try so hard in building RCP + Webstart. But webstart console closed immediately after launching.

could you please send me your eclipse RCP projects by mail? so that I can trace what is wrong.

Email: kelvin382@gmail.com
4 楼 defrag_sly 2008-12-04  
kelvinlaw 写道

i get the following error in running this tutorial, could you please give me some hints in solving the error? thanks

下图中说的xml文件缺少必要内容的问题,我这边没有遇到过,也许是因为JWS的版本的问题。
不好意思。不能帮你。
3 楼 defrag_sly 2008-12-04  
kelvinlaw 写道



有些eclipse版本可能没有wpf这个jar包。建议打开site/features/下的rcp**.jnlp文件,将这个jar包导入关联删掉。
相同的也可能没有其他类的jar包。这主要是由于eclipse分为不同的版本,win/linux等等所以删掉这个关联并不影响程序运行。
2 楼 kelvinlaw 2008-12-04  
1 楼 kelvinlaw 2008-12-04  
i get the following error in running this tutorial, could you please give me some hints in solving the error? thanks



相关推荐

Global site tag (gtag.js) - Google Analytics