Hello everybody,
I want to load and run a macro file in my plugin. The macro file is located in the same jar with the plugin, therefore I use Macro_Runner to load and run it. I specified the name of the macro file like "JAR:macros/macro.ijm", but runMacroFromJar adds a / and so the macro is not found. What's the correct way to load a macro from a jar or is this just a bug in the method runMacroFromJar(String name) in class Macro_Runner on line 48: InputStream is = pcl.getResourceAsStream("/" + name); may should look like InputStream is = pcl.getResourceAsStream(name) Kind regards Markus |
The JAR Resources Demo plugin at
http://rsb.info.nih.gov/ij/plugins/pcl-demo.html demonstrates how to load and run a macro from a JAR file. -wayne __________________________________ From: Markus Sutter [[hidden email]] Sent: Monday, July 26, 2010 10:31 AM To: List IMAGEJ Subject: Macro_Runner.java runMacroFromJar(String name) adds an extra "/" to the name, bug? Hello everybody, I want to load and run a macro file in my plugin. The macro file is located in the same jar with the plugin, therefore I use Macro_Runner to load and run it. I specified the name of the macro file like "JAR:macros/macro.ijm", but runMacroFromJar adds a / and so the macro is not found. What's the correct way to load a macro from a jar or is this just a bug in the method runMacroFromJar(String name) in class Macro_Runner on line 48: InputStream is = pcl.getResourceAsStream("/" + name); may should look like InputStream is = pcl.getResourceAsStream(name) Kind regards Markus |
In reply to this post by Markus Sutter
Hi,
thx for your hint. I checked this demo already, but I thought there must be a simpler solution then loading the macro manually to a String and pass it do runMacro. Hence I looked into the IJ sources and found ij.plugin.Macro_Runner, which offers exactly that what I was looking for with the method runMacroFromJar(String name). But then I bumped into the problem with the extra "/". Which I think is just a bug in the method runMacroFromJar(String name) in class Macro_Runner on line 48: InputStream is = pcl.getResourceAsStream("/" + name); may should look like InputStream is = pcl.getResourceAsStream(name) (note: there is also the confusing ij.macro.MacroRunner) I hope I could clarify a bit and I don't have to copy this getText method from the JAR Resources Demo. Kind regards Markus |
On Jul 28, 2010, at 10:56 AM, Markus Sutter wrote:
> Hi, > thx for your hint. I checked this demo already, but I thought there must be a simpler solution then loading the macro manually to a String and pass it do runMacro. Hence I looked into the IJ sources and found ij.plugin.Macro_Runner, which offers exactly that what I was looking for with the method runMacroFromJar(String name). But then I bumped into the problem with the extra "/". > Which I think is just a bug in the method runMacroFromJar(String name) in class Macro_Runner > on line 48: > InputStream is = pcl.getResourceAsStream("/" + name); may should look like > InputStream is = pcl.getResourceAsStream(name) > > (note: there is also the confusing ij.macro.MacroRunner) > > I hope I could clarify a bit and I don't have to copy this getText method from the JAR Resources Demo. > Kind regards > Markus The ImageJ 1.44e daily build adds the static method Macro_Runner.runMacroFromJar(String name, String arg) for running a macro contained in a JAR file. This method does not add an extra "/" to the name and it allows you to pass an argument to the macro. Here is an example call: Macro_Runner.runMacroFromJar("macro.txt", "argument") -wayne |
Free forum by Nabble | Edit this page |