Login  Register

Re: Macro_Runner.java runMacroFromJar(String name) adds an extra "/" to the name, bug?

Posted by Rasband, Wayne (NIH/NIMH) [E] on Jul 29, 2010; 2:32am
URL: http://imagej.273.s1.nabble.com/Macro-Runner-java-runMacroFromJar-String-name-adds-an-extra-to-the-name-bug-tp3687452p3687454.html

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