wood burning stoves*
The moose likes IDEs, Version Control and other tools and the fly likes Plugin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Plugin" Watch "Plugin" New topic
Author

Plugin

RajHans Kumar
Greenhorn

Joined: Apr 20, 2011
Posts: 19
Hi

I am trying to create a Plugin in eclipse but have been struggling .
The main purpose is to call some functions from some classes using the plugin.
I have been following the below link:
http://www.eclipse.org/articles/viewArticle/ViewArticle2.html
However,wasn't succesful.

Thanks in advance
saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

Hi Rajhans,

What is the problem you are getting in the article ?
It is a tutorial for creation of a view.Are you geting any error ?

cheers,
saurav


Be Objectively Oriented.Explore the power of OOPs.
My Blog, Eclipse EMF Query committer.
RajHans Kumar
Greenhorn

Joined: Apr 20, 2011
Posts: 19
Hi Sourav

I have a Project named org.eclipse.examples.helloworld inside which I have the src folder and inside that I have the package org.eclipse.examples.helloworld.The Java class HelloWorldAction is inside this package.
Now I dont know how to "Run->Run As->Run-time Workbench " as in the article.
I have tried running the entire package as Run Configuration but I am getting an error

"java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:556)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)"

Could you let me know
1.How do I run the WorkBench ?
2.How to deal with this exception ?

Thanks

saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

Hi Rajhans,

Have you created your project as a plug-in project. ?
A plug-in project would essentialy have a manifest.mf file.

Once you have a manifest.mf file you can right click on it and say Run as 'Eclipse application'

So, runtime workbench is nothing but another instance of the Eclipse application where you can
test your plugin.
Let me know if you have further problems.

Cheers,
Saurav
RajHans Kumar
Greenhorn

Joined: Apr 20, 2011
Posts: 19
Hi Sourav

Thanks for the quick reply .
I have made a Plug -in project which has manifest.mf file
The contents of which are as below:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Helloworld
Bundle-SymbolicName: org.eclipse.examples.helloworld;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6


The plugin.xml has some warnings though ,don't know again if thats the cause:

<?xml version="1.0"?>
<plugin
name="Eclipse Hello World Example"
id="org.eclipse.examples.helloworld"
version="0.0.0"
provider-name="OTI">

<requires>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.ui"/>
</requires>

<runtime>
<library name="helloworld.jar"/>
</runtime>

<extension point = "org.eclipse.ui.actionSets">
<actionSet
id="org.eclipse.examples.helloworld.HelloWorldActionSet"
label="Hello World"
visible="true"
description="The action set for the Eclipse Hello World example">
<menu
id="org.eclipse.examples.helloworld.HelloWorldMenu"
label="Samples">
<separator name="samples"/>
</menu>
<action id="org.eclipse.examples.helloworld.actions.HelloWorldAction"
menubarPath="org.eclipse.examples.helloworld.HelloWorldMenu/samples"
toolbarPath="Normal"
label="Hello World"
tooltip="Press to see a message"
icon="icons/helloworld.gif"
class="org.eclipse.examples.helloworld.HelloWorldAction"/>
</actionSet>
</extension>
</plugin>

I am still getting the same exceptions

Is there something wrong in the above two files ??

saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

You are using a very old tutorial dated back to 2001.
Most of the plugin.xml syntaxes seem to be outdated.

The best way would be to go to the Eclipse.
Window->Show Views->Cheatseets.

Cheatseets are interactive way to create the plug-ins.

Other waywould be Just create a plug-in project.While you create a plug-in
project you will get a set pre-defined templates like a plug-in with View.

I hope this will help.
Also let me know which version of Eclipse you are using if the problem persists.

cheers,
Saurav
RajHans Kumar
Greenhorn

Joined: Apr 20, 2011
Posts: 19
Hey Sourav

Thanks a lot mate
That worked and I was able to create a simple plugin using the cheatcodes

However,when I tried creating a plug-in extension I faced quite a few problems :
As in the cheatcode:-
"To create a view class, perform the following steps:
Click the "class" hyperlink under "Extension Element Details" to start the "New Java Class" wizard
Accept the default values and click the "Finish" button to exit the wizard "

Now the view and category for the org.eclipse.ui.views weren't coming by default so I changed the plugin.xml as
<extension
id="com.example.helloworld.view.helloworldcategory"
name="Hello World!"
point="org.eclipse.ui.views">
<category
id="com.example.helloworld.view.helloworldcategory"
name="Hello World!">
</category>
<view
id="com.example.helloworld.view.helloworld"
name="Hello World!"
icon="icons/view16/sections.png"
category="com.example.helloworld.view.helloworldcategory"
class="com.example.helloworld.view.SampleView">
</view>
</extension>

However,wasn't getting a hyperlink for the class as in:
"To create a view class, perform the following steps:
Click the "class" hyperlink under "Extension Element Details" to start the "New Java Class" wizard
Accept the default values and click the "Finish" button to exit the wizard "

My eclipse version is 3.5.0


Thanks in advance


RajHans Kumar
Greenhorn

Joined: Apr 20, 2011
Posts: 19
Hi

I have also created the class now ,however I am getting an exception on clicking the Hello World button as in the Window-Show-Other menu .

"Could not create the view: com.example.helloworld.view.SampleView cannot be cast to org.eclipse.ui.IViewPart"


Could anyone let me know how to resolve this ?

Thanks
saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

Hi Rajhans,

Does your SampleView class implements IViewPart. ?
If you are trying to create a view and contributing to the View extension point.
Your view must implement IViewPart.

Cheers,
Saurav
RajHans Kumar
Greenhorn

Joined: Apr 20, 2011
Posts: 19
Hi Sourav

Thanks got my problem fixed
One last question though
Can I run a plugin from the same instance of the Eclipse ?

Regards
saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

Well, the code you write needs an execution environment.
So if you write a plug-in in the design time and then for testing you need to launch a separate eclipse
application which becomes your runtime.The design time plug-in becomes a part of your target platform.

Lets say you want to test your plug-in in the design time iteself.
You need to have the built plug-in as a jar in the plug-ins folder of the IDE.
In this case the plug-ins in the plug-in folder becomes your target platform.

Check my blog for some more insight into eclipse related stuffs.

cheers,
Saurav
RajHans Kumar
Greenhorn

Joined: Apr 20, 2011
Posts: 19
Thanks mate
I tried making a Jar out of the plugin and keeping it in the Plugin folder of the eclipse installed directory .However I am getting an error now
"Could not create the view: Plug-in com.example.helloworld was unable to load class com.example.helloworld.views.com."
RajHans Kumar
Greenhorn

Joined: Apr 20, 2011
Posts: 19
Hi Sourav

Was able to run the plugin in the same instance of Eclipse so was successful in doing that.

However ,of-late I have a different problem. I tried changing the code in the class given in the Extensions and tried redeploying the plugin .
But ,I am getting an error as
"An error has occurred when activating this view
java.lang.NullPointerException"

I have tried cleaning my eclipse and also using a differnt workspace ,but still the same error persists even if I try using a different instance of eclipse to run the plugin.

Could you tell me what the problem might be ?

Regards
 
 
subject: Plugin