I have created an eclipse plugin and I wanted to deploy during eclipse runtime. I have below package structure.
com.myplugin
|
---resources
|
---server.bat
As part of the plugin job, "server.bat" file should be executed.
I packaged the plugin as .jar file including resouces folder in the binary and placed in to the eclipse "plugins" folder.
Plugin took effect and it does work fine, but I have a problem while executing the "server.bat" file, which is inside the jar that I generated. The error message says:
"Windows cannot find "resources\server.bat" make sure you typed name correctly and try again"
I tried with relative paths and absolute paths, but it didnt work.
Here is the code doing that 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 the "fileURL" output:
file:/D:/Program Files/IBM/SDP/configuration/org.eclipse.osgi/bundles/2392/1/.cp/resources/server.bat
I am not sure this is correct.
Hope this is clear enough to answer the question.
Alternatively, please suggest some other way, such as creating features to deploy the plugin with folder structure. I haven't tried this option yet.
I found this worked well with Eclipse RCP 4, This code took the given gif image from a jar file that was in the given plugin
....
I made it worked using ProcessBuilder. Below is the code snippet..
Ofcourse, i extracted the jar and put that directory to plugins folder of eclipse.
Use the second solution of http://www.vogella.com/blog/2010/07/06/reading-resources-from-plugin/
And don't forget to export the files you want to access in the build configuration of your plugin.
I have had a similar problem when I export my plugin. I had to refer an exe file stored in my plugin jar file. When the plugin was exported I can not access the zipped file, while it is accessible when I develop the plugin cause eclipse looks for the file in my "development folder". To solve the problem I created a plugin feature and in the "Included Plug-ins" tab of feature.xml I checked the option
for the plugin which contains the exe file. Using this option you will find your plugin files in a folder under the eclipse plugin folder and you will be able to access them as regular files.
For example
Otherwise I think you should decompress your jar.
Hope this help.
EDIT
As I said you can create a feature project(for an example look here) and when you add your plugins, check the option "Unpack the plug-in archive after the installation." Eclipse will do the work for you and you will find your plugin unzipped in the eclipse plugin folder. This solved the problem for me.
Your code seems ok. Note that: