ij-48.a-jar // Exception in thread "main" java.lang.NoSuchMethodError: ij.Menus.getImageJPath()Ljava/lang/String;

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ij-48.a-jar // Exception in thread "main" java.lang.NoSuchMethodError: ij.Menus.getImageJPath()Ljava/lang/String;

David Pirotte
Hello,


The following clojure code [see the watershed.clj script below] used to perfectly work until ij-1.47.m.jar

        -] I have just updated our fiji/imagej to the very latest available version of imagej and fiji
        -] now i run ij-1.48a.jar

Since this update, i get this error [see below as well]. Any one could kindly tell me what the problem is?

Many thanks,
David

1] this is how I execute the clojure script [I did install clojure-1.4.jar manually]

cd /usr/local/src/Fiji.app/jars; java -cp clojure-1.4.0.jar:headless.jar:ij-1.47m.jar:ij-1.48a.jar clojure.main /usr/lpdi/projects/clojure/watershed/watershed.clj /tmp/CPOL_60.png.noise-0.0.threhold-0.032 CPOL_60_seeds png

2] here is the error message

Exception in thread "main" java.lang.NoSuchMethodError: ij.Menus.getImageJPath()Ljava/lang/String;
        at ij.Prefs.getImageJDir(Prefs.java:234)
        at ij.IJ.getDirectory(IJ.java:1479)
        at ij.Menus.addLuts(Menus.java:333)
        at ij.Menus.addSubMenu(Menus.java:328)
        at ij.Menus.getMenu(Menus.java:698)
        at ij.Menus.addMenuBar(Menus.java:169)
        at ij.IJ.init(IJ.java:326)
        at ij.IJ.run(IJ.java:253)
        at ij.IJ.run(IJ.java:317)
        at user$eval5.invoke(watershed.clj:16)
        at clojure.lang.Compiler.eval(Compiler.java:6514)
        at clojure.lang.Compiler.load(Compiler.java:6955)
        at clojure.lang.Compiler.loadFile(Compiler.java:6915)
        at clojure.main$load_script.invoke(main.clj:283)
        at clojure.main$script_opt.invoke(main.clj:343)
        at clojure.main$main.doInvoke(main.clj:427)
        at clojure.lang.RestFn.invoke(RestFn.java:457)
        at clojure.lang.Var.invoke(Var.java:427)
        at clojure.lang.AFn.applyToHelper(AFn.java:172)
        at clojure.lang.Var.applyTo(Var.java:532)
        at clojure.main.main(main.java:37)

3] here is th watershed.clj script

(import '(ij IJ)
        '(ij ImagePlus))

(let [args *command-line-args*
      its-length (count args)]
  (if (= its-length 3)
    (let [d-name (nth args 0)
          f-name (nth args 1)
          f-ext (nth args 2)
          filename (str d-name "/" f-name "." f-ext)
          wsfilename (str d-name "/" f-name ".ws." f-ext)
          imp (IJ/openImage filename)]
      (IJ/run imp "8-bit" "")
      (IJ/run imp "Watershed", "")
      (IJ/save imp wsfilename)
      (System/exit 0))
    (do
      (println "ERROR: watershed.clj, wrong number of arguments")
      (System/exit -1))))

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ij-48.a-jar // Exception in thread "main" java.lang.NoSuchMethodError: ij.Menus.getImageJPath()Ljava/lang/String;

dscho
Hi David,

On Mon, 12 Aug 2013, David Pirotte wrote:

> The following clojure code [see the watershed.clj script below] used to
> perfectly work until ij-1.47.m.jar
>
> -] I have just updated our fiji/imagej to the very latest
> available version of imagej and fiji
> -] now i run ij-1.48a.jar
>
> Since this update, i get this error [see below as well]. Any one could kindly tell me what the problem is?
>
> Many thanks,
> David
>
> 1] this is how I execute the clojure script [I did install clojure-1.4.jar manually]
>
> cd /usr/local/src/Fiji.app/jars; java -cp clojure-1.4.0.jar:headless.jar:ij-1.47m.jar:ij-1.48a.jar clojure.main /usr/lpdi/projects/clojure/watershed/watershed.clj /tmp/CPOL_60.png.noise-0.0.threhold-0.032 CPOL_60_seeds png

The problem is actually headless.jar. If you let Fiji perform its runtime
patching, it should be able to run that code. But introducing headless.jar
(which was last generated from ImageJ 1.45b unless you generated a new
one) into the class path will be incompatible with current ImageJ 1.x.

> 2] here is the error message
>
> Exception in thread "main" java.lang.NoSuchMethodError: ij.Menus.getImageJPath()Ljava/lang/String;
> at ij.Prefs.getImageJDir(Prefs.java:234)

Due to certain limitations in Java/AWT (and ImageJ 1.x missing separation
between GUI and processing logic), we need to override the ij.Menus class
completely in headless mode.

The current way Fiji does it is to hand off to ImageJ2 which inherited
Fiji's headless support and added robustness to it. It also does it via
runtime patching now, rather than putting a possibly-incompatible
headless.jar into the class path before ij.jar.

FWIW by far the easiest way to run Clojure scripts with Fiji is to call

        ./ImageJ-<platform> <script>.clj

It will even default to headless mode when no GUI is detected.

Ciao,
Johannes

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html