imagej2 icon indicating copy to clipboard operation
imagej2 copied to clipboard

Remove tools.jar dependency

Open hinerm opened this issue 10 years ago • 8 comments

We are currently shipping com.sun:tools.jar on the ImageJ update site. This is improper usage of an intended system scope dependency, which should and of questionable legality. It also causes duplicate class conflicts with the Fiji javac fork.

To fully remove our dependency on com.sun:tools:

  • [x] Remove the com.sun:tools dependency from ImageJA, Minimaven and SciJava scripting-java
  • [x] Replace necessary usage with 'javax.tools.ToolProvider.getSystemJavaCompiler'. Note that this implies a minimum Java version of 1.6
  • [ ] Turn off the multitude of error messages that are printed by minimaven.. these are intended to be debug logging statements..
  • [ ] Update the imagej-launcher to read and write JDK locations in the imagej.cfg. We should auto-detect when possible, merge with existing (e.g. user-specified) entries, and prune invalid locations
  • [ ] Create an options menu to select JDK version, driven by the .cfg file
  • [x] Make the java 8 compiler be detected first before javac's compiler so we can make things work in both java 6 and java 8
  • [x] Remove com.sun:tools.jar and javac fork from the update site (or put this stuff on java 8 update site)

hinerm avatar Dec 18 '14 18:12 hinerm

This needs to be robustly tested - e.g. if running from a JRE can the compiler in a JDK be located? Does using a different java location (like internet plugins) still work?

hinerm avatar Nov 25 '15 16:11 hinerm

First bit of progress:

I have a minimaven branch. Using it, I was able to successfully compile a .java file from the script editor after removing:

  1. tools.jar
  2. javac.jar

from my Fiji install when launched with a Java 7 JDK.

hinerm avatar Dec 02 '15 18:12 hinerm

note that compilation still works with these jars as well

hinerm avatar Dec 02 '15 18:12 hinerm

To make Java work in the Script Editor out of the box with Java 8, I removed tools and javac JAR files from the core update sites. See https://github.com/fiji/fiji/issues/119#issuecomment-234063994

I am leaving this issue open until we can thoroughly review the status of all the bullet points above, though.

ctrueden avatar Jul 28 '16 18:07 ctrueden

Just as the above mentioned PR to stop shipping javac with Fiji has been merged, the corresponding command line option --javac should be removed from the launcher. I've tested it is still available on the latest version, but I couldn't find a corresponding ticket here on github...

ehrenfeu avatar May 15 '17 09:05 ehrenfeu

@ehrenfeu https://github.com/camlloyd/fiji/pull/4 was merged on a fork of the fiji repository, no?

Also, it was just Fiji's fork of javac that has been addressed in that PR, but references to tools.jar are still present.

I guess all of these lines need to be removed then, to get rid of tools.jar completely.

imagejan avatar May 15 '17 10:05 imagejan

@imagejan There is also this deprecated version of that script, and of course the ImageJ Launcher code itself.

Looking at ImageJ.sh though, I actually see no reason to remove the --javac etc. logic. It actually discovers tools.jar by looking at where the javac executable lives. It does not ship tools.jar. So it might actually still work! Why mess with it?

ctrueden avatar May 15 '17 16:05 ctrueden

Hello, I am trying to dowload the plugin filter " Escape_plugin" from "https://imagej.nih.gov/ij/plugins/download/Escape_Plugin.java" on Fiji (I have the last version updated). I saved the file in .jave extension and I tried to compile it using "Compile and run" but I got the error: "No javax.tools.JavaCompiler available. Checking for explicit javac. No javac.jar found (looked in D:\Utilisateurs\Y_Rekik\Fiji.app\jars)!" When I looked for javac file in jars directory, I found "javacpp-1.4.4.jar" and not "javac.jar".

I am working with huge stacks of images (from FIB-SEM) that I need to filter (eg. anistropic diffusion 3D) and each time, I make a mistake on launching an operation, I can not abort it! (which is not practical in my case because filtering takes a lot of time!). I am not used to programming and I really need your help! @hinerm @ctrueden Thank you in advance!

yousr96 avatar Jan 29 '20 11:01 yousr96