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
plot([1,2,3],[1,2,3]) 

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(ApplicationIcon.java:177)
	at com.mathworks.hg.peer.FigureClientProxy.getClientIcon(FigureClientProxy.java:973)
	at com.mathworks.hg.peer.FigureClientProxy$ShowEnabledHandler.initialize(FigureClientProxy.java:1247)
	at com.mathworks.hg.peer.FigureClientProxy.initializeShowHandler(FigureClientProxy.java:551)
	at com.mathworks.hg.peer.FigureClientProxy.doInitialize(FigureClientProxy.java:113)
	at com.mathworks.hg.peer.FigureMediator.initializeClient(FigureMediator.java:105)
	at com.mathworks.hg.peer.FigureHG2Mediator.initializeClient(FigureHG2Mediator.java:151)
	at com.mathworks.hg.peer.FigurePeer.doInitializePeer(FigurePeer.java:472)
	at com.mathworks.hg.peer.FigurePeer$2.run(FigurePeer.java:419)
	at com.mathworks.jmi.AWTUtilities$Invoker$5$1.run(AWTUtilities.java:591)
	at com.mathworks.mvm.context.ThreadContext$1.call(ThreadContext.java:76)
	at com.mathworks.mvm.context.ThreadContext.callWithContext(ThreadContext.java:105)
	at com.mathworks.mvm.context.ThreadContext.runWithContext(ThreadContext.java:73)
	at com.mathworks.mvm.context.MvmContext.runWithContext(MvmContext.java:107)
	at com.mathworks.jmi.AWTUtilities$Invoker$5.runWithOutput(AWTUtilities.java:588)
	at com.mathworks.jmi.AWTUtilities$Invoker$2.watchedRun(AWTUtilities.java:475)
	at com.mathworks.jmi.AWTUtilities$WatchedRunnable.run(AWTUtilities.java:436)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)

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
    _FIJI_dir\natives\windows-amd64\

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.

2 Likes