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 26, 2010; 3:51pm
URL: http://imagej.273.s1.nabble.com/Macro-Runner-java-runMacroFromJar-String-name-adds-an-extra-to-the-name-bug-tp3687452p3687455.html

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