On Feb 2, 2010, at 12:50 AM, Asier Aranbarri Beldarrain wrote:
Sorry Mirko, but I think it's not a problem of me making bad paths.
I mean, this is the code I have that DOES load the .properties from
a relative path:
URL entry = bc.getBundle().getEntry(".");
if (entry != null)
{
URLConnection connection = entry.openConnection();
if (connection instanceof BundleURLConnection)
{
URL fileURL = ((BundleURLConnection) connection).getFileURL();
URI uri = new URI(fileURL.toString());
path = new File(uri).getAbsolutePath();
System.out.printf("This is the path: %s\n", path);
}
} //then make the load(), ...
It works on Eclipse, but not outside it. The code you passed me just
writes the path eclipse is working on, but what I need is to pass
a .jar to another client and load the .properties WITHOUT knowing in
what path he will put the .properties file. The only thing he needs
is to put the .properties and the .jar in the same folder, don't
know if I explain.
Anyway, thanks for all,
Here is your problem.
URL entry = bc.getBundle().getEntry(".");
There is no guarantee where this URL will point to in an OSGi
container and is implementation specific. As I mentioned in an
earlier message, dumping a properties file into this same area is very
dangerous and could have unanticipated consequences to the OSGi
container.
Frequently, the cause of such conundrums arrises when one attempts to
go against the grain of the way a framework was meant to work. To
untie such a knot I would ask you what is it that you are trying to
do? More specifically, why are you attempting to pass a jar and a
properties file in the same folder to some "client"? What are the
details of the situation that force us to work such a constrained way?
Regards,
Alan
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev