问题
I created a Eclipse plug-in project by selecting a plug-in template provides by the eclipse. Then i ran the plug-in it opened another eclipse and the plug-in executed there.Why so? is the plugin taking eclipse's application class to create workbench?
回答1:
As an elaboration of "If you want to run the plugin in your main workspace you will have to export the plugin and install it in your main Eclipse." that @greg-449 had in his answer. You can do this.
Step 1 - Export your plugin
From the File menu, choose Export... and then choose the Deployable plug-ins and fragments
wizard.
Step 2 - Configure your Wizard Options
- Select the plug-ins you want to export.
- As the destination, choose
Install into host
- Press Finish
Step 3 - Confirm unsigned content
As you are probably not signing your plug-in, but you do trust it, say Yes to the Warning: you are installing software that contains unsigned content.
Step 4 - Restart Eclipse
Restart Eclipse when prompted to to enable the plug-ins.
Result
You should now see your new plug-ins. To make this example I used the new Plug-in wizard and choose the "Hello, World Command" template. The arrows below point to the contributions in the UI that the plug-in made.
回答2:
When you run a plugin (Run As > Eclipse Application) Eclipse starts a new instance of Eclipse including your plugin and uses a new workspace. This enables you to test the plugin without damaging your main Eclipse installation and workspace.
If you want to run the plugin in your main workspace you will have to export the plugin and install it in your main Eclipse.
If you want to run your plugin as part of an RCP you can set the application or product launched in the 'Run > Run Configurations...' entry.
For example:
Here I am running a product called 'greg.music.e4.rcp.product'
来源:https://stackoverflow.com/questions/33124278/launching-eclipse-plug-in-template