Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Platform.getBundle() returns NULL everytime
icon5.gif  Platform.getBundle() returns NULL everytime [message #648561] Thu, 13 January 2011 14:23 Go to next message
Tom Brandenburg is currently offline Tom BrandenburgFriend
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Hello all,

currently I want to access resources stored in one of my plugins. At first I wondered how this should work and then I found the solution with Platform.getBundle().
So I have a static main method in a workspace plugin project and the same should access the resources. But when I want to get my plugin/bundle with the method above NULL is returned. NULL is also returned for definetely installed plugins like "com.ibm.icu" etc., on which the workspace project is also dependent.

Code:
public class CMain {

	public static void main(String[] args) {
		Bundle bundleTest = Platform.getBundle("com.ibm.icu"); // or all other bundles

		System.out.println(bundleTest.toString());
	}

}


What am I doing wrong? Or is this even the right way to do so?

Thanks in advance and best regards
Tom

[Updated on: Thu, 13 January 2011 14:25]

Report message to a moderator

Re: Platform.getBundle() returns NULL everytime [message #648571 is a reply to message #648561] Thu, 13 January 2011 14:35 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 01/13/2011 09:23 AM, Tom Brandenburg wrote:
>
> public class CMain {
>
> public static void main(String[] args) {
> Bundle bundleTest = Platform.getBundle("com.ibm.icu");
>
> System.out.println(bundleTest.toString());
> }
>
> }

The OSGi framework must be running in order for Platform to work
(especially methods like getBundle(*)). i.e. run as an eclipse app.

PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Platform.getBundle() returns NULL everytime [message #648576 is a reply to message #648571] Thu, 13 January 2011 14:57 Go to previous messageGo to next message
Tom Brandenburg is currently offline Tom BrandenburgFriend
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Hey Paul,

thanks for your answer and suggestion. I'll test it.

And is there a way to access resources in a plugin with a workspace project and execution as a Java application?

Thanks and cheers,
Tom
Re: Platform.getBundle() returns NULL everytime [message #648622 is a reply to message #648576] Thu, 13 January 2011 17:19 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 01/13/2011 09:57 AM, Tom Brandenburg wrote:
> And is there a way to access resources in a plugin with a workspace
> project and execution as a Java application?

I'm not sure what you mean. Resources (as appropriate) can still be
kept with classes and loaded via the standard java loading mechanism,
like getClass().getResourceAsStream(*).

Running as a "java app" means running a bunch of jars. SWT and JFace
can be run as a bunch of java apps (OSGI bundles are valid java jars),
but thing that depend on core.runtime and Platform cannot exist without
running the OSGi framework.

What exactly are you trying to do (or how did you get in this scenario)?
If you are writing a plugin, simply use the OSGi Bundle.getEntry(*)
mechanism. Why do you think you need to run your bundle as a java app?

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Platform.getBundle() returns NULL everytime [message #649012 is a reply to message #648622] Mon, 17 January 2011 09:32 Go to previous message
Tom Brandenburg is currently offline Tom BrandenburgFriend
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Quote:
Why do you think you need to run your bundle as a java app?


Hey Paul,

sry I ment "eclipse app", not "java app". Sorry for the misunderstanding I also don't know why I have called it java app Smile

I have a workflow contained in an xPand project, which I want to deploy as a plugin, so that a future workspace project can use this workflow out of the plugin. And because of this use case it is not my aim to run this plugin as an eclipse app. That's why I asked for another way to access resources in a plugin.

I'll read something about getClass().getResourceAsStream(*) and Bundle.getEntry(*) and put a feedback here. Thanks for your help!

Bye Tom Smile
Previous Topic:How to have a fragment project replace a directory of files
Next Topic:Relaunching Debugger with Project Variables
Goto Forum:
  


Current Time: Thu Mar 28 15:45:33 GMT 2024

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

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

Back to the top