permaculture playing cards*
The moose likes Java in General and the fly likes New folder inside an existing plugin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "New folder inside an existing plugin" Watch "New folder inside an existing plugin" New topic
Author

New folder inside an existing plugin

Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
Hi all,

I am extending org.eclipse.wst.xml.ui and I have created a "properties" folder which contains, of course, some properties file I need during execution.

This "properties" folder is at the root of the plugin, but how can I access to it?
I mean, which is the path?

"./properties"? I tried but it seems not working.

Thanks
Marco
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
If the properties file is inside your source you can use
Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
For example:

my source code is in the folder org.eclipse.wst.xml.ui which contains some of classes for default XML Editor inside Eclipse.

I have added org.eclipse.wst.xml.ui/properties.

So, I will try with your code but, what is "Trial"?

Thanks
Marco
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Trial can be any of your custom class where you wish to refer the .properties file.
Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
John Jai wrote:Trial can be any of your custom class where you wish to refer the .properties file.


Therefore is it the name of the class where I am calling the properties file from?
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Therefore is it the name of the class where I am calling the properties file from?

Not necessarily be. But please try and let us know if you were able to access the .properties file. It can be any class present in your source file.
Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
Ok, thanks.
I will try tomorrow at work, not I am at home

I will write tomorrow.

Thanks
Marco
Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
It seems not working...I explain better what I am doing.

I have Test1.java whose path is /org/eclipse/wst/xml/ui/internal/contentassist/Test1.java

Here I am trying to load a file which is in the root of my plugin inside folder /properties.

I tried with



but I get a NullPointerException

Thanks
Marco
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

You are not supposed to use the Class and resource to load from a Plugin. An Eclipse plugin is a bundle and lives in a Context of an OSGi-instance. Hence, you need to use the Bundle and Context.



Of course, if you are in the bundle you want to read from, you can get the Bundle from the current Context.

Alternatively you can also use URL directly.

Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
Ove Lindström wrote:You are not supposed to use the Class and resource to load from a Plugin. An Eclipse plugin is a bundle and lives in a Context of an OSGi-instance. Hence, you need to use the Bundle and Context.



This works fine.

Thanks a lot
Marco
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38057
    
  22
Too difficult for "beginning". Moving thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New folder inside an existing plugin
 
Similar Threads
Include Hibernate in Eclipse
Tomcat Startup Problem
Environment setup for SCDJWS 5 EXAM preparation.
How to remove a plug-in in Eclipse?
Galileo + AspecJ