How do I insert own plugins in imagej?

Hi, I have two own plugins for a special filtering and calibration and I have can´t get them work on the newest version of imagej(Fiji),better they are installed but they not submerged under plugins.
The java skript for one of these is:

var imp = WindowManager.getCurrentImage();
if(imp)
{
    title = imp.getTitle();
    width = imp.getWidth();
    height = imp.getHeight();    
                
    var pi = 3.14159;
    

    mradius = 10;
    
    dialogi = GenericDialog("Gfilter...")
    dialogi.addStringField("Mask radius:", mradius)
    
    dialogi.showDialog();
    
    mradius = parseFloat(dialogi.getNextString())

    roi = imp.getRoi(); 
    p = roi.getPolygon(); 

    if(!dialogi.wasCanceled())
    {
        if(p.npoints>0)
        {
            for (k=0; k<p.npoints; k++) 
            {
                px = p.xpoints[k] - width/2;
                py = p.ypoints[k] - height/2;
                
                maximadistance = Math.sqrt(px*px+py*py);
                angle = Math.atan(-py/px)*180/pi;

                // The first order
                for(i = 0; i<6;i++)
                {
                    cx = maximadistance*Math.cos((angle+60*i)*pi/180)+width/2.-mradius/2;
                    cy = -maximadistance*Math.sin((angle+60*i)*pi/180)+height/2.-mradius/2;
                    
                    IJ.makeOval(cx, cy, mradius, mradius);
                    IJ.run("Cut");
                }
                
                // The second order
                maximadistance = 2*maximadistance*Math.cos(pi/6)
                for(i = 0; i<6;i++)
                {
                    cx = maximadistance*Math.cos((30+angle+60*i)*pi/180)+width/2.-mradius/2;
                    cy = -maximadistance*Math.sin((30+angle+60*i)*pi/180)+height/2.-mradius/2;
                    
                    IJ.makeOval(cx, cy, mradius, mradius);
                    IJ.run("Cut");
                }
                    
            }
        }
    }    
}

Sorry if my english is bad, it is not my native language. Maybe someone can help me, I think I make a basic thing wrong. Because by the older version, I just copy the plugin in the plugin-folder and it showed up in the programm.

Did you try to save your script into ./Fiji.app/plugins/ (or ./Fiji.app/plugins/Scripts/Your/Menu) and make sure that the file name contains an underscore (_) and ends in .js?

See Adding scripts to the Plugins menu.

Hi,
thanks for the help. Ok I inserted the underscore and now it appears.
But when I want to use it the following error arise:
nashorn:mozilla_compat.js:67 ReferenceError: “WindowManager” is not defined

after this there is a long list of at…I will copy it here too:

at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
    at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319)
    at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291)
    at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1432)
    at jdk.nashorn.internal.scripts.Script$Recompilation$13$1362A$\=nashorn\!mozilla_compat.value-1$__noSuchProperty__(nashorn:mozilla_compat.js:67)
    at jdk.nashorn.internal.scripts.Script$14$g_Filter.:program(C:\Users\Timmo\DOCUME~1\FIJI-W~1\Fiji.app\plugins\gFilter\g_Filter.js:9)
    at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640)
    at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:228)
    at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:446)
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:403)
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399)
    at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:150)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
    at org.scijava.script.ScriptModule.run(ScriptModule.java:173)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:167)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
    at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:191)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

You have to import each Java class you’re using in your script:

importClass(Packages.ij.WindowManager);

Please read the Javascript scripting documentation on the wiki. The script editor does not auto-import all ij classes any more, see here for some background.

1 Like

Ok, thanks for all the help. I will try this. If there are still problems I will write here again, but don´t expect a new commend till wednesday afternoon, because I´m on a conference.