Acessing resources in plugin jar file

I want to be able to access files that I’‘ve built into my plugin (the ones you place in /lib when you’'re doing the ant jar stuff).

I want to access them through Java though, none of this C:\path\to\Spark\plugins\pluginName\lib\blah.dll

I know I need to do something along the lines of this.getClass().getClassLoader().getResource("/blah.dll")

but this doesn’'t seem to work, it returns null. I only seem to be able to access the classes in plugin-classes.jar

How do I get it to spot the files that we place in /lib ?

This must be possible since the import statements know to look in /lib for the necessary Jar files there for importing right?

maybe I should be using the PluginClassLoader() I’'m thinking, but not sure what to put for the params…

:: shakes head :: I’'ve been trying to figure this out all day. Any help would be great.

Message was edited by: heather

Hi Heather,

Try this instead:

File libDir = (new File(PluginManager.PLUGINS_DIRECTORY, "MyPlugin/lib")).getAbsoluteFile();

Then if you want to access a file in the libDir you can do this:

libDir.getAbsolutePath() + File.pathSeparator + myFileName;

Hope that helps,

Ryan

Yep, that works perfectly. Thanks again Ryan