[英]How to make simplistic RCP application really standalone?
This is total refactoring of my old question on new level of knowledge. 这是我对新知识水平的旧问题的全面重构。
Questions summary 问题摘要
My eclipse product is not working. 我的eclipse产品无效。 Does it require any additional feature?
是否需要任何其他功能?
Creating Simplistic RCP Application 创建简单的RCP应用程序
At this moment all wizard features were disabled and I press Finish
button. 此时所有向导功能都被禁用,我按下
Finish
按钮。 As a result, Eclipse creates nearly empty project with MANIFEST.MF
and build.properties
files only. 因此,Eclipse仅使用
MANIFEST.MF
和build.properties
文件创建几乎为空的项目。
Now I am creating an application. 现在我正在创建一个应用程序。 Application is an extension to
org.eclipse.core.runtime.applications
extension point, which is implemented inside org.eclipse.core.runtime
plug-in. Application是
org.eclipse.core.runtime.applications
扩展点的扩展,它在org.eclipse.core.runtime
插件中实现。 So I add this plug-in as a dependency: 所以我将此插件添加为依赖项:
This creates new node in Package Explorer
, called Plug-in Dependencies
: 这将在
Package Explorer
创建一个名为Plug-in Dependencies
新节点:
Now I add new extension to this point in my plug-in: 现在我在插件中添加新的扩展名:
I am giving an id myappid
to my application and assign a class myproject.Application
to it. 我给我的应用程序提供了一个id
myappid
,并为它分配了一个类myproject.Application
。
This creates a file plugin.xml
这将创建一个文件
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="myappid"
point="org.eclipse.core.runtime.applications">
<application
cardinality="singleton-global"
thread="main"
visible="true">
<run
class="myproject.Application">
</run>
</application>
</extension>
</plugin>
which contains all this information. 其中包含所有这些信息。 Also this file is referred from
build.properties
: 此文件也是从
build.properties
引用的:
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
Simultaneously MANIFEST.MF
becomes invalid, since it is now required to be singleton, which is set either automatically, or by check box from Overview
tab: 同时
MANIFEST.MF
变为无效,因为它现在需要是单例,可以自动设置,也可以通过Overview
选项卡中的复选框设置:
Note, that although my application id is myappid
, this name is not fully qualified. 请注意,虽然我的应用程序ID是
myappid
,但此名称不是完全限定的。 Fully qualified name appears from concatenation between plug-in id and this is. 完全限定名称出现在插件ID之间的连接中,这是。 In my case it is
myproject.myappid
. 在我的例子中,它是
myproject.myappid
。
Now I am going (back) to Extensions
tab of manifest editor, and create class file for application by clicking class
hyperlink: 现在我将(返回)清单编辑器的
Extensions
选项卡,并通过单击class
超链接为应用程序创建类文件:
This invokes New Java class
wizard and finally creates java
file and opens it in the editor: 这将调用
New Java class
向导,最后创建java
文件并在编辑器中打开它:
package myproject;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
public class Application implements IApplication {
@Override
public Object start(IApplicationContext context) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public void stop() {
// TODO Auto-generated method stub
}
}
I am adding only one line here, inside start
method: 我在这里只添加一行,在
start
方法中:
System.out.println("Hello world from myproject");
Now after saving all I am able to run application from Overview
tab of manifest editor. 保存完所有后,我可以从清单编辑器的
Overview
选项卡运行应用程序。 Program works and prints what is expected: 程序工作并打印预期的内容:
Hello world from myproject
来自myproject的Hello world
Printing occurs in Eclipse Console View. 在Eclipse控制台视图中进行打印。
Creating Product Configuration 创建产品配置
Now I am creating a product configuration, which is required for export wizard can work. 现在我正在创建一个产品配置,这是导出向导可以工作所必需的。
Creating and setting product file simultaneously adds extension to plugin.xml
file to org.eclipse.core.runtime.products
extension point. 同时创建和设置产品文件会将
plugin.xml
文件的扩展名添加到org.eclipse.core.runtime.products
扩展点。
On the Overview
tab of product file editor, I press New
button, which invokes New Product Definition
window: 在产品文件编辑器的
Overview
选项卡上,我按New
按钮,它会调用New Product Definition
窗口:
I filled it with new product name, product id and also referred application, which fully qualified name I derived before. 我填写了新的产品名称,产品ID和引用的应用程序,我之前得到的完全限定名称。
Now my plugin.xml
file lokks like follows: 现在我的
plugin.xml
文件lokks如下:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="myappid"
point="org.eclipse.core.runtime.applications">
<application
cardinality="singleton-global"
thread="main"
visible="true">
<run
class="myproject.Application">
</run>
</application>
</extension>
<extension
id="myproductid"
point="org.eclipse.core.runtime.products">
<product
application="myproject.myappid"
name="MyProduct">
</product>
</extension>
</plugin>
You see that our product is represented there. 您看到我们的产品在那里代表。
Now I need to do a trick which I was not able to find for a long time. 现在我需要做一个我很长时间都找不到的技巧。
Despite the fact that product file refers to application and plugin correctly, it is not included into product content automatically. 尽管产品文件正确引用了应用程序和插件,但它并未自动包含在产品内容中。 I regard this as Eclipse bug.
我认为这是Eclipse的bug。
So, I go to Dependencies
tab of product file editor, and add my own plugin to it: 所以,我转到产品文件编辑器的
Dependencies
选项卡,并添加我自己的插件:
After that I need to press magic button Add Required Plug-ins
之后,我需要按魔术按钮
Add Required Plug-ins
Now I am able to run my application from within Overview
panel of product file editor and it works as expected (printing text inside console view). 现在,我可以从产品文件编辑器的
Overview
面板中运行我的应用程序,它可以按预期工作(在控制台视图中打印文本)。
Exporting Product 出口产品
Only now I am able to utilize export wizard 只有现在我才能使用导出向导
This will create directory D:\\myproject
and put everything into it. 这将创建目录
D:\\myproject
并将所有内容放入其中。 It can be ran by running eclipse.exe
inside 它可以通过在里面运行
eclipse.exe
来运行
Unfortunately, it does nothing, although, cause no exceptions. 不幸的是,它没有做任何事情,但是,没有例外。
Questions 问题
1) Why my exported program does nothing? 1)为什么导出的程序什么都不做? Does it require eclipse console or something?
它需要eclipse控制台吗? Or it just doesn't work?
或者它只是不起作用?
2) How to make the program to print? 2)如何打印程序? Is it possible to provide GUI console like in Eclipse?
是否可以像Eclipse一样提供GUI控制台? Or is it possible to force it to print to operating system terminal/console?
或者是否可以强制它打印到操作系统终端/控制台?
1) Check you environment, especially JAVA_OPTS. 1)检查你的环境,尤其是JAVA_OPTS。 If there's anything there, unset the variable and try running again
如果那里有任何东西,请取消设置变量并再次尝试运行
2) Check the JDK on your path with "java -version". 2)使用“java -version”检查路径上的JDK。 Is it a 1.7.0 version (as specified in the execution environment) and does it match the eclipse launcher (ie if you are using 64-bit eclipse, it should be a 64-bit JDK and not a 32-bit one, and vice-versa).
它是1.7.0版本(在执行环境中指定)并且它与eclipse启动器匹配(即如果您使用的是64位eclipse,它应该是64位JDK而不是32位版本,并且反之亦然)。 If there is a mismatch, fix (set PATH / JAVA_HOME to proper location and retry running).
如果存在不匹配,请修复(将PATH / JAVA_HOME设置为正确的位置并重试运行)。 Note that on Windows the default JRE may be configured in the registry and your path may be clear.
请注意,在Windows上,可以在注册表中配置默认JRE,并且您的路径可能是明确的。 Check the Java settings in Control Panel to see what's the preferred one.
检查“控制面板”中的Java设置以查看首选的设置。 Heck, even better, don't risk it: add the following lines in eclipse.ini instead, pointing to the correct JDK location, ABOVE the -vmargs line:
哎呀,甚至更好,不要冒险:在eclipse.ini中添加以下行,指向正确的JDK位置,超过-vmargs行:
-vm
C:\path\to\the\proper\jdk\bin\javaw.exe
3) Look in the folder "configuration/.log" (timestamp is a UNIX long). 3)查看文件夹“configuration / .log”(时间戳是UNIX长)。 Sometimes when a workspace doesn't get created Eclipse will log errors there...
有时当工作空间没有被创建时,Eclipse会在那里记录错误......
4) Try running with "eclipse -consoleLog" 4)尝试使用“eclipse -consoleLog”运行
PS I haven't actually tried your steps, but the above is the list of things that have bitten me in the past (with 2 being the most common one)... :-) PS我还没有尝试过你的步骤,但以上是过去曾经咬过我的东西的列表(其中2是最常见的)... :-)
I think your program works correctly, but you are not seeing anything because the output is not directed anywhere. 我认为你的程序工作正常,但你没有看到任何东西,因为输出不是指向任何地方。 Please edit the file eclipse.ini and add two options before the vmargs:
请编辑文件eclipse.ini并在vmargs之前添加两个选项:
-console
-安慰
-consoleLog
-consoleLog
Then open a terminal/command interpreter in the folder and execute: 然后在文件夹中打开一个终端/命令解释器并执行:
eclipse
日食
Then see whether there is still no output. 然后看看是否仍然没有输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.