How to get the installation directory for a plugin under Eclipse getbundle

Source: Internet
Author: User

Actually getting the plugin's "Install directory" is a bit of a mistake, because the plug-ins under Eclipse are all installed under plugins.

However, most people will search for the "Eclipse plugin directory" As soon as they think of the location of a plugin, so I wrote the title.

As a rookie, if I'm going to use something I haven't tried before, I usually start with a very small engineering test. This method is right.

So I created a new Java project under Eclipse (note that this is a curse, you'll understand later).


Then a Java file with the main method is added, and the

Org.eclipse.core.runtime (Platform's method is all in this area)

Org.eclipse.equinox.common (Org.eclipse.core.runtime.IStatus in this area)

Org.eclipse.osgi

Wait for the jar to be introduced

and then use

		Bundle Bundle = Platform.getbundle ("Com.core.runtime");
		if (bundle!= null)
			System.out.println (bundle.tostring ());
		else 
			System.out.println ("return null!");

This code to obtain the directory of Plug-ins, the result is null and dead.

Looking for, and then found the Eclipse forum up, there is a person with the same problem, and then understand.

To make this platform.getbundle work, the OSGi framework must run. P This is the original address: Click on the Open link


Of course, the role of Plug-ins is to extend the Eclipse platform, if you are a Java program (not the Eclipse plug-in), there should be no "plug-in" the kind of resources to say it, have been compiled into class.

It means platform.getbundle This method can only be used in plug-in development, and I started out as a Java project, so I always get null.

The primary view, the mistake please revise.

On 01/13/2011 09:57 AM, Tom Brandenburg wrote:
> and are there a way to access resources into a plugin with a Workspac E
> Project and execution as a Java application?

I ' m not sure what for you mean.  Resources (as appropriate) can still 
is kept with classes and loaded via the standard Java loading mechanism 
GetClass (). getResourceAsStream (*).

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

What exactly are you are trying to doing (or how are did you with this scenario)? 
If you are are writing a plugin, simply use the OSGi bundle.getentry (*) 
mechanism. Why do you have need to run your bundle as a Java app?

PW



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.