-
Notifications
You must be signed in to change notification settings - Fork 2
ImageJ Launcher Troubleshooting
Updated: July 17th, 2022
If you try to use IJP-Color plugins with a typical ImageJ distribution you may see issues that should not be there. Plugins like, the Calibrator or the Calculator, may fail to start with some cryptic errors (see examples in section [Appendix_-_Examples_of_Errors_with_Default_Launchers] below).
Those issues is related to the ImageJ launcher - a small application that is used to start actual ImageJ application. It is different on different operating systems, but it is causing similar set of problems. ImageJ is not loading key components of the plugins, the JavaFX native binaries.
There is a workaround, till the issue is fixed. Details for each OS are below. Those best/easy solutions I could figure out, but may not be optimal. If you know a better solution please share in Discussions.
Here we assume that you are using the default ImageJ installation downloaded using link on the Download page. At the time of writing that link was called "ImageJ bundled with 64-bit Java 1.8.0_172" and pointed to file named "ij153-win-java8.zip", Instructions were tested with Windows 10.
With the standard distribution, ImageJ is launched using ImageJ.exe
. You will need to launch ImageJ in an alternate
way, using following script:
set MAXIMUM_MEMORY=2g
start /b jre\bin\javaw.exe -Xmx%MAXIMUM_MEMORY% -cp plugins/ij-plugins/*;ij.jar ij.ImageJ
In the ImageJ directory, next to ImageJ.exe
, create file called ImageJ.bat
and copy the content above. You can also
download it from this link: ImageJ.bat (use Save Link As...)
To start ImageJ double-click on the ImageJ.bat
Note: In the example above ImageJ will start with maximum allocation of 2GB of RAM (due to set MAXIMUM_MEMORY=2g
).
Changing the Maximum Memory using "Edit" > "Options" > "Memory & Threads" will not work when launching ImageJ this way.
To change the Maximum Memory you will need to change the script above modifying MAXIMUM_MEMORY
. For instance to set
the maximum memory to 4GB you will need to set MAXIMUM_MEMORY
to 4g
set MAXIMUM_MEMORY=4g
You can also express that in MB for instance, 4096m
set MAXIMUM_MEMORY=4096m
Technically speaking, the directory with IJP-Color JAR files needs to be added to ImageJ class path.
One way to do it is to edit ImageJ launcher script. It is located inside ImageJ application directory,
under Contents/MacOS/ImageJ
. Around line 301 you should see something like this:
exec "$JAVACMD" \
-cp "${JVMClassPath}" \
-Xdock:icon="${ResourcesFolder}/${CFBundleIconFile}" \
-Xdock:name="${CFBundleName}" \
${JVMOptions:+$JVMOptions }\
${JVMDefaultOptions:+$JVMDefaultOptions }\
${JVMMainClass}\
${JVMArguments:+ $JVMArguments}
You will need to change line 302 from:
-cp "${JVMClassPath}" \
to
-cp "plugins/ij-plugins/*:${JVMClassPath}" \
Work in progress...
Example of a default ImageJ launcher error when attempting to start IJP Color Calculator on Mac OS X:
When you expand the details you could see:
java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
at javafx.scene.image.Image.validateUrl(Image.java:1135)
at javafx.scene.image.Image.<init>(Image.java:625)
at javafx.scene.image.ImageView.<init>(ImageView.java:194)
at scalafx.scene.image.ImageView.<init>(ImageView.scala:55)
at ij_plugins.color.ui.util.IJPUtils$.createHeaderNode(IJPUtils.scala:154)
at ij_plugins.color.ui.converter.ColorConverterView.createGidPane(ColorConverterView.scala:148)
at ij_plugins.color.ui.converter.ColorConverterView.pane(ColorConverterView.scala:59)
at ij_plugins.color.ui.converter.ColorConverterPlugin$$anon$1.<init>(ColorConverterPlugin.scala:75)
at ij_plugins.color.ui.converter.ColorConverterPlugin$$anon$2.<init>(ColorConverterPlugin.scala:77)
at ij_plugins.color.ui.converter.ColorConverterPlugin.run$$anonfun$1(ColorConverterPlugin.scala:78)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at scalafx.application.Platform$$anon$1.run(Platform.scala:149)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found
at javafx.scene.image.Image.validateUrl(Image.java:1120)
... 15 more
javafx.fxml.LoadException:
file:/private/var/folders/fs/l6zflk2x57vdz5vqdm0vqc7c0000gn/T/AppTranslocation/CAA2C16C-2A92-4F4D-844A-A8B2A6C1A215/d/ImageJ.app/plugins/ij-plugins/ijp-color-ui_3-0.11.4.3-SNAPSHOT.jar!/ij_plugins/color/ui/calibration/ColorCalibrator.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2949)
at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2793)
at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2758)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2624)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
at org.scalafx.extras.mvcfx.MVCfx.createFXMLView(MVCfx.scala:124)
at org.scalafx.extras.mvcfx.MVCfx.view(MVCfx.scala:72)
at ij_plugins.color.ui.calibration.ColorCalibratorPlugin.run$$anonfun$1(ColorCalibratorPlugin.scala:102)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at scalafx.application.Platform$$anon$1.run(Platform.scala:149)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
Caused by: java.lang.ClassNotFoundException: javafx.geometry.Insets
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:3017)
at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:3006)
at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2947)
... 14 more