LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running ImageJ in LabVIEW

Solved!
Go to solution

Hi All,

I have been working on trying to integrate an ImageJ macro into LabVIEW. I would like to capture an image from a live camera (which I solved), run analysis on that image using my Image J macro, and then save all of that information. I feel like I'm very close to getting the results I want but I keep having issues with my command line attached to my System Execute VI. When I type my command line in command prompt, I get an "unable to access jar file error".  I attached a picture of what I have below. 

 

Thanks for any help I may receive on this topic, as a beginner I am very proud of myself but got stuck along the way.

0 Kudos
Message 1 of 6
(728 Views)

You will probably have to tell the Java environment where it can find according java libraries.

When you executed that command on the normal command line you cd into that directory and executed the command. This also sets the "Current Directory" for the Java process that is instantiated. With System Exec you have a separate input control "Working Directory" , that you can use to set the directory the command will have set as current directory when it executes.

 

Currently your java.exe process has most likely no way to locate the ij.jar file as it starts up with a current directory that is where your java environment is installed at, instead of where your ij.jar file is located.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 6
(706 Views)

@SadeR34 wrote:

Hi All,

I have been working on trying to integrate an ImageJ macro into LabVIEW. I would like to capture an image from a live camera (which I solved), run analysis on that image using my Image J macro, and then save all of that information. I feel like I'm very close to getting the results I want but I keep having issues with my command line attached to my System Execute VI. When I type my command line in command prompt, I get an "unable to access jar file error".  I attached a picture of what I have below. 

 

Thanks for any help I may receive on this topic, as a beginner I am very proud of myself but got stuck along the way.


If you will provide the full absolute path to the jar and macro, then it should work:

Screenshot 2024-07-16 10.03.31.png

Message 3 of 6
(682 Views)

Thanks, for your help this proved that my command line was indeed wrong, but I believe I'm saving my macro incorrectly. I'm lost on how I should be saving it. I'm using windows and I'm saving the macro into my Fiji folder >macro, which is located on my desktop, and the computer is still unable to access the file when I run the command prompt even with the absolute path attached. Is there a special way I need to save my macro, so it can be called from the command line?

0 Kudos
Message 4 of 6
(629 Views)

@SadeR34 wrote:

Thanks, for your help this proved that my command line was indeed wrong, but I believe I'm saving my macro incorrectly. I'm lost on how I should be saving it. I'm using windows and I'm saving the macro into my Fiji folder >macro, which is located on my desktop, and the computer is still unable to access the file when I run the command prompt even with the absolute path attached. Is there a special way I need to save my macro, so it can be called from the command line?


Please do not confuse ImageJ and Fiji; they are slightly different things.

This is how it should work with Fiji, when placed on the Desktop:

Screenshot 2024-07-17 08.52.21.png

In your particular case, the command line should be like this:

 

"C:\Users\FS116605\OneDrive - First Solar\Desktop\Fiji.app\ImageJ-win64.exe" -macro "C:\Users\FS116605\OneDrive - First Solar\Desktop\Fiji.app\macros\Hello.ijm"

 

Also, be sure that Fiji (ImageJ-win64.exe) is not running when you call this, because after some faulty attempts, this executable can still be present in memory, and then it will (might) not work.

The script Hello.ijm can be created in Notepad, contains just one line:

print("Hello world");

 

Message 5 of 6
(600 Views)
Solution
Accepted by SadeR34

Sorry for the late response but I was able to get this solved and the issue was that I was originally calling for a jar file when my macro was not saved as a jar executable. I also had information in my command line wrong and needed two quotations instead of one at the end. To get the macro to run, I needed to open Fiji from the command line in headless mode. Andrey's command line was very close to what I needed but the command line below is what actually worked. I filled in some private information with just numeric fillers.

 

cmd /c "ImageJ-win64.exe --console -macro"C:\Users\890770789709\Downloads\Break Analysis macro r3.ijm"" (command line)

C:\Users\890770789709\Downloads\fiji-win64\Fiji.app (Working Directory)

 

Thanks for all of your help!!!

0 Kudos
Message 6 of 6
(413 Views)