Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Reading resources from a Eclipse plugin via command line options(Getting NullPointerException while reading plugin url via command line options)
Reading resources from a Eclipse plugin via command line options [message #1444727] Tue, 14 October 2014 13:20 Go to next message
Harshad Ghorpade is currently offline Harshad GhorpadeFriend
Messages: 2
Registered: October 2014
Junior Member
I want the functionality to retrieve currently loaded plugin URL, I have written a piece of code which is working correctly for the GUI option but not for command line options, I want to implement same functionality with command line also, but getting null pointer exception.

    final String PLUGIN_ID="com.plgins.CLIplugin";
	       public String getPluginUrl() throws Exception {
		String urlName = null;
		try {
			urlName = new File(
					new Path(FileLocator.toFileURL(
							Platform.getBundle(PLUGIN_ID).getEntry("/"))
							.getPath()).toString()).getAbsolutePath();
			} catch (Exception e) {
			e.printStackStrace();
		}
		return urlName;
	}


how to solve this problem?
Re: Reading resources from a Eclipse plugin via command line options [message #1444805 is a reply to message #1444727] Tue, 14 October 2014 15:21 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
On 14/10/2014 15:48, Harshad Ghorpade wrote:
> I want the functionality to retrieve currently loaded plugin URL, I have
> written a piece of code which is working correctly for the GUI option
> but not for command line options, I want to implement same functionality
> with command line also, but getting null pointer exception.

Not that this is a JDT question.. Please ask such questions better in
the Platform Forum.

If you look at the API doc for Platform.getBundle() it states that:

[..]Returns the resolved bundle with the specified symbolic name that
has the highest version. If no resolved bundles are installed that have
the specified symbolic name then null is returned. [...]

So it's perfectly normal that null is returned and you need to handle
that case: The platform only returns a bundle object if the given bundle
is in resolved state, and yours probably is not resolved when you're
running in headless mode.


> final String PLUGIN_ID="com.plgins.CLIplugin";
> public String getPluginUrl() throws Exception {
> String urlName = null;
> try {
> urlName = new File(
> new Path(FileLocator.toFileURL(
> Platform.getBundle(PLUGIN_ID).getEntry("/"))
> .getPath()).toString()).getAbsolutePath();
> } catch (Exception e) {
> e.printStackStrace();
> }
> return urlName;
> }
>
> how to solve this problem?
Re: Reading resources from a Eclipse plugin via command line options [message #1445284 is a reply to message #1444805] Wed, 15 October 2014 08:29 Go to previous message
Harshad Ghorpade is currently offline Harshad GhorpadeFriend
Messages: 2
Registered: October 2014
Junior Member
Thanks Felix for pointing out issue, is it possible to do this programmatically, I tried to check status using OSGi commands, but not able to perform any of operation(install, start, ss) on this plugin, as it is showing only "org.eclipse.osgi_3.7.2.v20120110-1415" as an ACTIVE bundle.
Previous Topic:How do I resolve binding for instance creation with diamond operator?
Next Topic:Check box is blur out - need to enable it
Goto Forum:
  


Current Time: Fri Apr 19 06:43:49 GMT 2024

Powered by FUDForum. Page generated in 0.01573 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top