Trouble executing jar Plugin - nosuchmethod error

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

Trouble executing jar Plugin - nosuchmethod error

Influenza
hello Everyone,

i developed a IJ Plugin with Eclipse and it used work in that environment. Now I want to publish the Plugin but I have some trouble with instlling the Plugin:

I took the jar file from the workspace directory and added a plugins.config similiar to the example. The plugin is now available at the Menu "Plugin-...".
When I tried to start it, it first threw me an UnsupportedClassVersionError whereupon I changed the System Library from Java 1.7. to Java 1.6. After replacing the .jar file and updating the .config I now get:

ImageJ 1.47v; Java 1.6.0_20 [32-bit]; Windows 7 6.1; 14MB of 1536MB (<1%)
 
java.lang.NoSuchMethodError: Gui: method <init>()V not found
        at Mikro_EvalDesk.run(Mikro_EvalDesk.java:24)
        at ij.IJ.runUserPlugIn(IJ.java:195)
        at ij.IJ.runPlugIn(IJ.java:160)
        at ij.Executer.runCommand(Executer.java:128)
        at ij.Executer.run(Executer.java:64)
        at java.lang.Thread.run(Thread.java:619)

Gui is the GUI of that Plugin and is defined in a class within the .jar file.
Can anyone solve my problem?

Thanks for your support!
Steven

Reply | Threaded
Open this post in threaded view
|

Re: Trouble executing jar Plugin - nosuchmethod error

Michael Schmid
Hi Steven,

the error seems to occur in your code, and it is difficult to guess what is the problem without seeing the code!

One possible thing to check for: Does your Gui class have a constructor? If it extends some other (super-)class, and you have somewhere
  Gui myGui = new Gui();
or
  new Gui().someMethodOfGui(args);

you need a constructor. The default would be

public class Gui extends SuperGuiClass {
  public Gui() {
     super();
  }
 // and the rest of the code ...
}

A typical way to get such an error seems to be if a no-argument constructor SuperGuiClass() does not exist. In this case, you might call super(someNiceDefaultArguments) in the constructor.


Michael
________________________________________________________________
On Mar 14, 2014, at 11:45, Influenza wrote:

> hello Everyone,
>
> i developed a IJ Plugin with Eclipse and it used work in that environment.
> Now I want to publish the Plugin but I have some trouble with instlling the
> Plugin:
>
> I took the jar file from the workspace directory and added a plugins.config
> similiar to the example. The plugin is now available at the Menu
> "Plugin-...".
> When I tried to start it, it first threw me an UnsupportedClassVersionError
> whereupon I changed the System Library from Java 1.7. to Java 1.6. After
> replacing the .jar file and updating the .config I now get:
>
> ImageJ 1.47v; Java 1.6.0_20 [32-bit]; Windows 7 6.1; 14MB of 1536MB (<1%)
>
> java.lang.NoSuchMethodError: Gui: method <init>()V not found
> at Mikro_EvalDesk.run(Mikro_EvalDesk.java:24)
> at ij.IJ.runUserPlugIn(IJ.java:195)
> at ij.IJ.runPlugIn(IJ.java:160)
> at ij.Executer.runCommand(Executer.java:128)
> at ij.Executer.run(Executer.java:64)
> at java.lang.Thread.run(Thread.java:619)
>
> Gui is the GUI of that Plugin and is defined in a class within the .jar
> file.
> Can anyone solve my problem?
>
> Thanks for your support!
> Steven
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Trouble-executing-jar-Plugin-nosuchmethod-error-tp5006911.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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

Re: Trouble executing jar Plugin - nosuchmethod error

Influenza
Hy Michael,

thanks for your response.

My gui.class has a correct constructor, the whole Plugin works fine in the eclipse environment. It just throws the error when I try to implement the .jar folder from the eclipse project into the ImageJs Plugins directory.

here a excerpt from the programm:

public class Mikro_EvalDesk implements PlugIn{
       
...
        public void run(String arg) {

                this.gui=new Gui();

               
               
        }

}




public class Gui extends JFrame implements ActionListener {
       
...

                public Gui() {
                        super("Evaluation Desk");
                        ...
                }
                       
...
}

All classes of the programm are in the .jar folder as .class files but it still throws me the method not found. Do you have any other ideas?

best regards



Reply | Threaded
Open this post in threaded view
|

Re: Trouble executing jar Plugin - nosuchmethod error

dscho
Hi Steven (is Influenza your nickname?),

On Mon, 17 Mar 2014, Influenza wrote:

> My gui.class has a correct constructor, the whole Plugin works fine in the
> eclipse environment. It just throws the error when I try to implement the
> .jar folder from the eclipse project into the ImageJs Plugins directory.

This suggests that you are haunted by an incompatible Gui.class (please
note the upper-case 'G'... Java *is* case-sensitive, even if the
underlying file system might not be).

In Fiji, we have this command Plugins>Utilities>Find Jar For Class.
Calling it with the class name "Gui" leads to this output:

-- snip --
The class Gui is contained in
/Applications/Fiji.app/plugins/Volume_Viewer-2.01.1-SNAPSHOT.jar
-- snap --

The problem is of course that more than just one plugin might want to use
the class name "Gui". To counter that, Sun invented the concept of
"packages". If you put your source into, say, goerlich/Gui.java and write
"package goerlich;" anywhere before the first "import" statement, the
class name will be actually "goerlich.Gui". Must less prone to lead to
confusion.

Right now, the Gui class is in the so-called "default package", i.e. in no
package at all. The same is true for Volume Viewer's, so it's either your
plugin that gets broken by that problem, or the Volume Viewer.

Having said that, the tireless Curtis Rueden put in a lot of effort to fix
the Volume Viewer with regards to classes in the default package. I just
failed to upload the plugin until five minutes ago. If you update, you
will get those fixes.

Thus, now you should not see the problems any longer even if you leave the
Gui class in the default package. However, for exactly the same reason
Volume Viewer's classes moved into appropriate packages, I strongly
suggest you do the same.

Ciao,
Johannes

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

Re: Trouble executing jar Plugin - nosuchmethod error

Influenza
Hy Johannes,

yes Influenza is my Nickname :)

Thanks for the response, I had indeed a naming problem caused by the dublicated class name "Gui" (ij.gui vs. MyPlugin.Gui). Renaming my class "Gui" solved the problem!