Calling compiled matlab code with ImageJ/Java8

Hi all

I am having trouble calling compiled matlab code with the latest version of ImageJ on Windows 10.

The problem occurs with any code that shows figures. I made this example.

During trouble shooting I tried a number of things to try and figure if it is a java 8 error.

I tried calling this code using matlab-imagej scripting, with java 8

version -java

It confirms matlab is using java 1.8, and it works.

However when I called compiled code from the newest Imagej/Fiji using with java 1.8 I get many errors related to IconEnumerationUtils (see below).

Does this make sense to anybody?? I figure maybe it is a java8 matlab issue… but it seems to work when running though scripting. I suppose the compiled code may be using different classes or something though.

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Could not initialize class com.mathworks.common.icons.IconEnumerationUtils
	at com.mathworks.common.icons.ApplicationIcon.getIcon(
	at com.mathworks.hg.peer.FigureClientProxy.getClientIcon(
	at com.mathworks.hg.peer.FigureClientProxy$ShowEnabledHandler.initialize(
	at com.mathworks.hg.peer.FigureClientProxy.initializeShowHandler(
	at com.mathworks.hg.peer.FigureClientProxy.doInitialize(
	at com.mathworks.hg.peer.FigureMediator.initializeClient(
	at com.mathworks.hg.peer.FigureHG2Mediator.initializeClient(
	at com.mathworks.hg.peer.FigurePeer.doInitializePeer(
	at com.mathworks.hg.peer.FigurePeer$
	at com.mathworks.jmi.AWTUtilities$Invoker$5$
	at com.mathworks.mvm.context.ThreadContext$
	at com.mathworks.mvm.context.ThreadContext.callWithContext(
	at com.mathworks.mvm.context.ThreadContext.runWithContext(
	at com.mathworks.mvm.context.MvmContext.runWithContext(
	at com.mathworks.jmi.AWTUtilities$Invoker$5.runWithOutput(
	at com.mathworks.jmi.AWTUtilities$Invoker$2.watchedRun(
	at com.mathworks.jmi.AWTUtilities$
	at java.awt.event.InvocationEvent.dispatch(
	at java.awt.EventQueue.dispatchEventImpl(
	at java.awt.EventQueue.access$500(
	at java.awt.EventQueue$
	at java.awt.EventQueue$

btw: You cannot use the matlab sdk with java 8. However the resulting jar files seem to work

I eventually solved this, it turns out it is not a java-8 issue. So just in case someone else has the same problem here is what I did.

  1. I had to rollback guava-19.0.jar to guava-18.0.jar. Matlab doesn’t seem to distribute guava, but does distribute an older, related library, google-collect.jar. I think something must of changed in guava-19, that is not compatible with something in google-collect.

  2. I had to copy gluegen-rt.dll, nativewindow_awt.dll, nativewindow_win32.dll from
    C:\Program Files\MATLAB\MATLAB Runtime\v91\bin\win64 to

I need to investigate how to add the matlab native path(s) to the fiji’s native search paths, but I have it working for now.