Compilation problems

fiji

#1

Dear all

i know this issue has been discussed several times, but still I am unable to solve the problem.

I run FIJI under Windows 10 with Java 8 installed. When I try to compile and run a script from the script editor it comes back with the message:

“No javac.jar found (looked in C:\Users\spaciorn\Desktop\FIJI~1.APP\jars)!”

After reading several of the previous posts on this issue I did install the JDK (jdk-11.0.1) but that did no help. I guess it would also be necessary to set some environment variables for Java, but I don´t know exactly which ones.

Is there a place with a step by step set of instructions to solve this?

I am sure there must be a simple solution…

Thank you all!


#2

Have you read this post:

A JRE (<Java 9) comes not bundled with javac.

The JDK (<Java 9)come shipped with javac (/lib/tools.jar)

As a workaround you can download JavaSE (JDK) and copy the tools.jar library from jdk/lib to your application bundled JRE (jre/lib). Please use the same Java version! The embedded JRE version and installation folder on the OS can be found with Plugin->Utilities->ImageJ Properties

This should work if FIJI uses the default Java path for javac.

Note: The OpenJDK 11 has no tools.jar anymore (changed in Java 9). Javac can be found in module: jdk.compiler, see:

https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-7744EF96-5899-4FB2-B34E-86D49B2E89B6


#3

Thanks Bio7 for the reply. Yes, I had seen that post but was still confused (still am…).

As I had already downloaded JDK (jdk-11.0.1) and had no idea about the absence of tools.jar, I asked for help from our IT support. They somehow managed to install the correct version of the JDK and set the environment variables to use that installation and then I don´t get the “no javac” error anymore.

It seems to compile my code. However, it puts the compiled file in a temp folder. Here is the message I get:

HandleExtraFileTypes not up-to-date because 1 source files are not up-to-date (C:\Users\spaciorn\AppData\Local\Temp\java9051753140630652447\src\main\java\HandleExtraFileTypes.java)
Compiling 1 file in C:\Users\spaciorn\AppData\Local\Temp\java9051753140630652447

On that temp folder I find a TARGET subfolder that contains the corresponding .jar file and a CLASSES subfolder that contains the corresponding .class file.

I don´t really know which files I should use and/or put in the FIJI/plugins folder.

Checking the FIJI properties I get this (keeping only the lines that refer to Java):
java.version: 1.8.0_191
java.vendor: Sun Microsystems Inc.
java.home: C:\Program Files\Java\jdk1.8.0_191\jre
java.class.path: C:\Users\spaciorn\Desktop\Fiji.app/jars/imagej-launcher-4.0.5.jar
java.ext.dirs: C:\Program Files\Java\jdk1.8.0_191\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
java.io.tmpdir: C:\Users\spaciorn\AppData\Local\Temp

To use your suggestion of copying the tools.jar library from jdk/lib to my application bundled JRE ( jre/lib ) I downloaded a clean version of FIJI and checked first the properties. Here are the relevant lines, and I mark the differences from before:

java.version: 1.8.0_172
java.home: C:\Users\spaciorn\Desktop\FIJI-W~1\Fiji.app\java\win64\jdk1.8.0_172\jre
java.class.path: C:\Users\spaciorn\Desktop\FIJI-W~1\Fiji.app/jars/imagej-launcher-4.0.5.jar
java.ext.dirs: C:\Users\spaciorn\Desktop\FIJIW~1\Fiji.app\java\win64\jdk1.8.0_172\jre\lib\ext; C:\Windows\Sun\Java\lib\ext
java.io.tmpdir: C:\Users\spaciorn\AppData\Local\Temp

So I understand this is the default Java path for javac.

I then copied the tools.jar library per your instructions:
FROM: C:\Program Files\Java\jdk1.8.0_191\lib
TO: C:\Users\spaciorn\Desktop\fiji-win64_clean\Fiji.app\java\win64\jdk1.8.0_172\jre\lib

I restarted FIJI and tried to compile my script but got the no javac error again.

Did I copy the correct “tools.jar” to the correct location? If so, why do I still get the same error?

This is all very complicated to the average user that just wants to compile a simple script. I am not an advanced programmer or a java programmer but I have been working with FIJI for years and have written relatively complex macros. So my impression is that I should be able to solve these problems in an easier way.

Any further help will be VERY welcome.

Thank you!


#4

I just realized that I get conflicting messages with this clean installation of FIJI and tools.jar copied to the jre/lib folder.

The Console shows the following message:
No javac.jar found (looked in C:\Users\spaciorn\Desktop\FIJI-W~1\Fiji.app\jars)!

However, the Script Editor outputs the following message:
HandleExtraFileTypes not up-to-date because 1 source files are not up-to-date (C:\Users\spaciorn\AppData\Local\Temp\java9033047788930458436\src\main\java\HandleExtraFileTypes.java)
Compiling 1 file in C:\Users\spaciorn\AppData\Local\Temp\java9033047788930458436

Which is the same I got before, with the original FIJI installation and java env variables changed.

So it complains about missing javac.jar but seems to compile, albeit in a temp folder.

Any hints?

Thank you again!


#5

Ok. I think it is easier for you to try a simpler way:

Just rename the embedded java folder of the application (FIJI.app/java) to something like javaOld.

Then the software won’t use the embedded FIJI jre (confusingly in a JDK folder - win64/jdk1.8.0_xxx/jre).

Instead it uses now the OS installed JDK (which is hopefully on your OS system PATH - if not install a JDK and and make sure the OS uses it!)

Now open the script editor of FIJI Plugins->New->Macro (Plugins->New->Plugin opens the ImageJ 1 editor which in my tests would’nt compile because of a wrong classpath!).

Switch to language Java, add your code and then save it to your plugins folder Fiji.app\plugins

Now compile the Java source with the script editor menu Run->Compile And Run

That should work.

Maybee @ctrueden could correct this information if I described something wrong or there is an easier way.


#6

Hello again,

Yes, this sequence works, somewhat. That is also what was done for the previous installation of FIJI I tested before your message.

However,It still compiles into that temp folder.

HandleExtraFileTypes not up-to-date because 1 source files are not up-to-date (C:\Users\spaciorn\AppData\Local\Temp\java6444940971914217602\src\main\java\HandleExtraFileTypes.java)
_Compiling 1 file in C:\Users\spaciorn\AppData\Local\Temp\java64449409719142176_02

So I still don´t know if that is the correct output and which files should be put in the plugins folder (apart from the original java file.

Thanks!


#7

Have you saved a new file to the plugin location. Just try it with a fresh example to see if that works.

Is HandleExtraFileTypes.java the file you want to compile?


#8

Yes, i did exactly what you suggested.

Opened an empty Script Editor window, copied the text from the original HandleExtraFileTypes to the editor, saved it in the plugins folder and then compiled…

Yes, it is file I am try to compile. I made a modification to try to open a specific image file type used in the institute I work for.


#9

I just compiled the file. Make sure that you save the file as HandleExtraFileTypes.java in the plugins folder after the Java is selected under the menu “Language”!

OK, I see, the class files are compiled correctly to the temp folder also in my installation.


#10

I just triple checked that I have the exact file in the correct folder. I am used to using the several language options in the Script Editor.

If the class files are output to the temp folder I should copy them back to the plugins folder, right? Which files exactly, just the .class? That´s what I would think…but there is also the .jar file.

I think we are almost there, but still I would expect the correct compiled files should be automatically output to the correct FIJI folders…


#11

Yes, it is a little bit confusing because I thought it would work the ImageJ1 way, too.

However it seems to be more optimized for writing the plugins for ImageJ2 and maven:

Normally the compiled *.class files should be sufficient but the produced *.jar in the target folder contains the *.class file already and could be copied to the plugins folder. It also has the classpath in the manifest file.


#12

Ok, I will copy the .jar back from temp to plugins.

Still, I have the strong impression this whole sequence should be easier and more streamlined.

Yes, I am aware of ImageJ2, Maven, etc, and I only use FIJI (not ImageJ1). I haven´t had time to work with Maven yet.

Well, thank you very much for your help!

Regards