How to refer a file from jar file in eclipse plugin -


i have created eclipse plugin , wanted deploy during eclipse runtime. have below package structure.

com.myplugin   |    ---resources        |         ---server.bat 

as part of plugin job, "server.bat" file should executed.

i packaged plugin .jar file including resouces folder in binary , placed in eclipse "plugins" folder.

plugin took effect , work fine, have problem while executing "server.bat" file, inside jar generated. error message says:

"windows cannot find "resources\server.bat" make sure typed name correctly , try again"

i tried relative paths , absolute paths, didnt work.

here code doing work:

url url = activator.getdefault().getbundle().getentry("/resources/server.bat");  string fileurl = filelocator.tofileurl(url).tostring();  string commandline = "cmd.exe /c start " +fileurl;  process process= runtime.getruntime().exec(commandline); 

i got "fileurl" output:

file:/d:/program files/ibm/sdp/configuration/org.eclipse.osgi/bundles/2392/1/.cp/resources/server.bat

i not sure correct.

hope clear enough answer question.

alternatively, please suggest other way, such creating features deploy plugin folder structure. haven't tried option yet.

i have had similar problem when export plugin. had refer exe file stored in plugin jar file. when plugin exported can not access zipped file, while accessible when develop plugin cause eclipse looks file in "development folder". solve problem created plugin feature , in "included plug-ins" tab of feature.xml checked option

unpack plug-in archive after installation.

for plugin contains exe file. using option find plugin files in folder under eclipse plugin folder , able access them regular files.

for example

    bundle bundle = <get bundle of plugin>;     url url = filelocator.find(bundle, new path(<relative path plugin root file>), null);     try {         url = filelocator.resolve(url);     } catch (ioexception e) {         e.printstacktrace();         return false;     } 

otherwise think should decompress jar.

hope help.

edit

as said can create feature project(for example here) , when add plugins, check option "unpack plug-in archive after installation." eclipse work , find plugin unzipped in eclipse plugin folder. solved problem me.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -