imagej / imagej-matlab

MATLAB integration with ImageJ data structures and runtime.
https://imagej.net/scripting/matlab
BSD 2-Clause "Simplified" License
14 stars 6 forks source link

Cannot run ImageJ.m from MATLAB with Java 1.8 #15

Closed kouichi-c-nakamura closed 6 years ago

kouichi-c-nakamura commented 6 years ago

About two months ago, I was able to run ImageJ.m successfully on MATLAB R2017b. Now I cannot do the same on R2018a. I've seen this issue reported here, but because the JAVA version is already 1.8, the same solution would not work for me.

 >> javaclasspath

        DYNAMIC JAVA PATH
        ...
    D:\Fiji.app\jars\imagej-matlab-0.7.2.jar                                 
        ...
    D:\Fiji.app\jars\scripting-matlab-0.5.1.jar                              
        ...

>> version -java
ans =
    'Java 1.8.0_144-b01 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode'

>> ImageJ
Undefined variable "ImageJMATLAB" or class "ImageJMATLAB.start".
Error in ImageJ (line 42)
        ImageJMATLAB.start(); 
42          ImageJMATLAB.start();

When I look at the source code of ImageJ.m , I found an alarming comment.

    %% Maybe open the ImageJ window
    import net.imagej.matlab.*;
    if open_imagej
        ImageJMATLAB.start();
    else
        % initialize ImageJ with the headless flag
        ImageJMATLAB.start('--headless');
    end

    % Make sure that the scripts are found.
    % Unfortunately, this causes a nasty bug with MATLAB: calling this
    % static method modifies the static MATLAB java path, which is
    % normally forbidden. The consequences of that are nasty: adding a
    % class to the dynamic class path can be refused, because it would be
    % falsy recorded in the static path. On top of that, the static
    % path is fsck in a weird way, with file separator from Unix, causing a
    % mess on Windows platform.
    % So we give it up as now.
    % %    imagej.User_Plugins.installScripts();

What does this mean? ImageJ.m won't work now? Or am I doing something wrong?

kouichi-c-nakamura commented 6 years ago

R2017b

I think it's better than R2018a (it showed a proper message), but stoppped at the same line.

>> addpath 'D:\Fiji.app\scripts\' % depends your Fiji installation
ImageJ
[INFO] Detected existing ImageJ; passing arguments along

--------------------------------------------------------------
ImageJ-MATLAB 0.7.2: MATLAB to ImageJ Interface
--------------------------------------------------------------
JVM> Version: 1.8.0_121
JVM> Total amount of memory: 1067520 Kb
JVM> Amount of free memory: 399158 Kb
Error using ImageJ (line 42)
Java exception occurred:
java.lang.NullPointerException

    at net.imagej.matlab.ImageJMATLAB.disableIJExit(ImageJMATLAB.java:247)

    at net.imagej.matlab.ImageJMATLAB.launch(ImageJMATLAB.java:156)

    at net.imagej.matlab.ImageJMATLAB.start(ImageJMATLAB.java:105)

    at net.imagej.matlab.ImageJMATLAB.start(ImageJMATLAB.java:92)

    at net.imagej.matlab.ImageJMATLAB.start(ImageJMATLAB.java:81)

42          ImageJMATLAB.start();
log4j:WARN No appenders could be found for logger (loci.formats.ClassList).
log4j:WARN Please initialize the log4j system properly.
hinerm commented 6 years ago

What does this mean? ImageJ.m won't work now? Or am I doing something wrong?

I believe that comment means that user-installed ImageJ plugins won't work in MATLAB.

About two months ago, I was able to run ImageJ.m successfully on MATLAB R2017b

If a tutorial doesn't work for you, please consider posting to the ImageJ forum or editing the wiki. The ImageJ wiki is for community contribution. Also, please note that the Pre-requisites section of the guide instructs the user to enable the ImageJ-MATLAB update site. I'm sure the ImageJ team would welcome suggestions on how to make instructions like this clearer.

I think it's better than R2018a (it showed a proper message), but stoppped at the same line.

Do you have the Java 8 update site enabled?

Can you try a fresh download of ImageJ?

The error has to do with not finding the legacy ImageJ. @ctrueden has anything changed with legacy ImageJ distribution?

kouichi-c-nakamura commented 6 years ago

Do you have the Java 8 update site enabled?

Sorry, but I don't understand what you mean by this. Can you clarify it further?

I've copied this issue to ImageJ forum. http://forum.imagej.net/t/cannot-run-imagej-m-from-matlab-with-java-1-8/10050

kouichi-c-nakamura commented 6 years ago

Sorry, but ImageJ.m worked today.

>> addpath 'D:\Fiji.app\scripts'
>> ImageJ
--------------------------------------------------------------
ImageJ-MATLAB 0.7.2: MATLAB to ImageJ Interface
--------------------------------------------------------------
JVM> Version: 1.8.0_144
JVM> Total amount of memory: 389120 Kb
JVM> Amount of free memory: 128790 Kb

-- Welcome to ImageJ-MATLAB --
ImageJ-MATLAB consists of an extensible set of commands for passing information between ImageJ and MATLAB.
See the individual sections below for a list of available commands.

For more information and examples see:
    http://imagej.net/MATLAB-Scripting

--- MATLAB Command Plugins ---

-- ImageJ MATLAB commands --

Usage: IJM.[command]
    help - prints a brief description of available commands
    getDataset - creates a MATLAB matrix from the active ImageJ image
    getDatasetAs(name) - creates a MATLAB matrix from the active ImageJ image, and assigns it to the specified variable name
    show(name) - takes the MATLAB matrix with the specified name and displays it as an image

--------------------------------------------------------------
Status> ImageJ is running.
--------------------------------------------------------------
log4j:WARN No appenders could be found for logger (loci.formats.ClassList).
log4j:WARN Please initialize the log4j system properly.