java - 如何让RCP应用程序真正独立?

标签 java eclipse eclipse-rcp

如果我创建 Headless Hello RCP应用

enter image description here enter image description here

我可以在 Eclipse 调试器下像任何普通的 java 应用程序一样运行它。它运行并将“Hello world”打印到 Eclipse 控制台中。

现在如何使其真正独立,即在没有我当前的 Eclipse 的情况下运行?

导出到可运行的 JAR 不适用于此类项目。

导出到 Eclipse 产品也不起作用。

更新

如果我为项目创建产品文件,则导出到产品开始工作,但应用程序本身在运行时开始崩溃。这可能是由于我在创建产品文件时做出的错误猜测。

首先创建的产品文件对我来说看起来没有填满:

enter image description here

尝试填写 Product我使用下拉菜单New按钮并从我当前的项目创建产品

enter image description here

我在填写Application时使用了一些猜测细胞。我在那里设置了一些条目,它在某种程度上与我当前的项目名称相对应。

导致应用程序崩溃并出现异常:

!ENTRY org.eclipse.equinox.launcher 4 0 2013-12-18 03:29:41.305
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:633)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

更新2

此常见问题解答条目http://wiki.eclipse.org/FAQ_How_do_I_create_an_Eclipse_product%3F描述了一些程序,但在现实中不起作用。

PLUGIN.XML

将产品扩展点添加到plugin.xml 时,Eclipse 发出警告

A minimum of 1 'provider' elements must be specified.
A minimum of 1 'product' elements must be specified.

enter image description here

常见问题解答中没有描述是否应该这样做以及如何做。

假设我们保持文件原样。

产品文件

后来创建产品文件时,也不清楚如何填写:

enter image description here

如果按照常见问题解答中的说明进行填写(参见上文,仅设置了产品 ID),则生成的应用程序不会异常运行:

!SESSION Wed Dec 18 13:32:36 MSK 2013 ------------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2013-12-18 13:32:36.300
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:633)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

更新3

我发现了以下几点:

1) 产品应在 plugin.xml 中进行描述文件并在.product中文件。在 plugin.xml将产品归档为 org.eclipse.core.runtime.products 的贡献点(<extension> tag)。这个标签plugin.xml文件可以通过 .product 自动创建文件创建向导,作者:New按钮。

2) 应用程序也出现在 plugin.xml 中文件作为对 org.eclipse.core.runtime.applications 的贡献。这应该在运行之前预先配置.product创建向导。 id plugin.xml中的应用程序文件不完全合格。如果前面加上插件名称,则会出现 FQN,插件名称写在 MANIFEST.MF 中文件。所以,在运行时.product创建向导应计算并设置应用程序的 FQN。

3)最终运行的结果不仅取决于以上所有,还取决于Debug As -> Debug ConfigurationsRun As -> Run Configurations 。有一个Plug-ins选项卡上有几个神奇的控件:

enter image description here

默认情况下,甚至不包括主应用程序。

关于这一切,我几乎可以走完全程,但最终遇到了新的障碍:

运行最终导出的应用程序时,出现异常:

!SESSION Wed Dec 18 19:04:36 MSK 2013 ------------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2013-12-18 19:04:36.695
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.RuntimeException: Could not find framework
        at org.eclipse.equinox.launcher.Main.getBootPath(Main.java:992)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:571)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1450)

更新4

添加org.eclipse.core.runtime后到 .product 的依赖项文件,最后一个问题解决了。下一个问题是一个异常(exception)

!SESSION 2013-12-18 19:43:31.136 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.7.0_40
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86_64

!ENTRY org.eclipse.osgi 4 0 2013-12-18 19:43:31.924
!MESSAGE Application error
!STACK 1
java.lang.RuntimeException: Application "MyApp.id1" could not be found in the registry. The applications available are: org.eclipse.equinox.app.error.
    at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:248)
    at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)

(本次运行中应用程序 ID 不同,但正确)

更新5

我发现我的应用程序类不存在于导出目录中的任何位置。

如何强制它去那里?

最佳答案

您需要的是Product File在你的应用程序中。为您的 RCP 应用程序创建一个产品,然后重点关注本教程的第 2 点(部署)。

祝你好运。

关于java - 如何让RCP应用程序真正独立?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20646515/

相关文章:

java - 对于 boolean 值,(p ^ q) 和 (p != q) 之间是否存在有用的区别?

java - Eclipse 随机停止加载

java - android eclipse 不创建空白 Activity

java - getActiveWorkbenchWindow 在 WorkbenchAdvisor.openWindows() 中返回 null

java - 如何将工作区资源 IFolder 写入磁盘(Eclipse RCP)?

java - 错误 404 - 使用@RestController 获取请求 - SpringBoot

java - 如何在Java程序中通过命令提示符运行.exe文件?

java - 增加一个unicode字符?

c - 如何在 Ubuntu 的 eclipse 中以 root 身份调试应用程序?

java - 束 XYZ 无法解析。原因 : Missing Constraint: Import-Package: ABC; version ="1.0.0" error in headless RCP standalone