imagej / imagej-ui-swing

ImageJ UI for Java Swing.
BSD 2-Clause "Simplified" License
10 stars 20 forks source link

Bug in the defaut FIJI editor (JavaScript interpreter) #73

Closed Bio7 closed 8 years ago

Bio7 commented 8 years ago

As noted in a recent discussion in the ImageJ forum. There seems to be a bug in the FIJI JavaScript interpreter when using the default script editor.

The script works in FIJI if you execute the script in the old JavaScript editor (Plugins->New->JavaScript)

The following simple script throws an error in the default FIJI script editor:

IJ.log("Hello")
IJ.selectWindow("Log");
IJ.saveAs("Text", "C:\Users\Avital\Desktop\Log.txt");

It seems that the ImageJ classes are not in the classpath of the JavaScript interpreter when using the default editor.

Error message: nashorn:mozilla_compat.js:67 ReferenceError: "IJ" is not defined

This error was confirmed to be true on Windows 64-bit and on MacOSX.

Bio7 commented 8 years ago

Information about Java:

os.arch => amd64 os.name => Windows 10 os.version => 10.0 java.version => 1.8.0_66 java.vendor => Oracle Corporation java.runtime.name => Java(TM) SE Runtime Environment java.runtime.version => 1.8.0_66-b18 java.vm.name => Java HotSpot(TM) 64-Bit Server VM java.vm.version => 25.66-b18 java.vm.vendor => Oracle Corporation java.vm.info => mixed mode java.awt.graphicsenv => sun.awt.Win32GraphicsEnvironment java.specification.name => Java Platform API Specification java.specification.version => 1.8 sun.cpu.endian => little sun.desktop => windows file.separator => \

ctrueden commented 8 years ago

You need to import the IJ class first:

importClass(Packages.ij.IJ)

See: http://imagej.net/JavaScript_Scripting#Importing_classes

If it still doesn't work after doing that, please reopen the issue.