Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "FAQ How do I find out the install location of a plug-in"

 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
This took me far too many hours, so I thought I would share. In your activator, implement the following:
 
This took me far too many hours, so I thought I would share. In your activator, implement the following:
<code>
 
        String rootDirectory;
 
  
public void start(BundleContext context) throws Exception {
+
<source lang="java">
super.start(context);
+
String rootDirectory;
//...
+
 
URL entry = context.getBundle().getEntry("/");  
+
public void start(BundleContext context) throws Exception {
rootDirectory = FileLocator.toFileURL(entry).getPath();  
+
    super.start(context);
}
+
    //...
</code>
+
    URL entry = context.getBundle().getEntry("/");  
 +
    rootDirectory = FileLocator.toFileURL(entry).getPath();  
 +
}
 +
</source>
 +
 
 +
 
 +
However, this solution may create unnecessary "/" at the beginning of the path. You may consider using this code instead:
 +
<source lang="java">
 +
String location = FileLocator.getBundleFile(context.getBundle()).getAbsolutePath();
 +
</source>

Latest revision as of 13:31, 31 December 2009

This took me far too many hours, so I thought I would share. In your activator, implement the following:

String rootDirectory;
 
public void start(BundleContext context) throws Exception {
    super.start(context);
    //...
    URL entry = context.getBundle().getEntry("/"); 
    rootDirectory = FileLocator.toFileURL(entry).getPath(); 
}


However, this solution may create unnecessary "/" at the beginning of the path. You may consider using this code instead:

String location = FileLocator.getBundleFile(context.getBundle()).getAbsolutePath();

Back to the top