I have one lib/ folder inside my Eclipse Plugin Project and on this folder I have a little script… But when I run the ‘Eclipse Plugin Project’ I cannot execute that script because I cannot access to that folder…
How can I fix this?
—
Thanks in advance
If you can execute the script by passing an
InputStreamor aStringto the interpreter, put in thesrc/folder, so it ends up on the classpath and usegetClass().getClassLoader().getResourceAsStream("script-name")to get anInputStreamIf the interpreter is external (like
bashor something that doesn’t implement the Java Scripting API), do the same. When you need to execute the script, create a stream and copy the script to a temporary file.Keeping the script in
lib/is also a bad idea since the plugin will be assembled into a single JAR file unless you turn that off, so you will end up with a script file inside of a JAR – again something which most interpreters can’t use.By using the classpath, you can let Eclipse figure out where the data is.