Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows temp directory not cleaned up when program messes with classpath #12

Closed
mabruce opened this issue Feb 24, 2015 · 2 comments
Closed
Labels

Comments

@mabruce
Copy link
Contributor

mabruce commented Feb 24, 2015

I'm calling code through javacpp in a plugin written for ImageJ/Fiji. Fiji, unfortunately, uses a native binary to startup the Java call and forces everything through its own launcher. This launcher in turn call everything else nicely, but as far as System.getProperty("java.class.path") is concerned, only that launcher's jar is on the classpath. On Windows, this results in the javacpp Loader class being unable to tie into the shutdown hook and clean up the temp directories (since the ImageJ launcher doesn't bother looking for the javacpp jar). To alleviate this, could line 572 in Loader.java be changed from:

command.add(System.getProperty("java.class.path"));

to

command.add( (new File(Loader.class.getProtectionDomain().getCodeSource().getLocation().toURI())).toString() );

That long and ugly string of commands locates the jar containing the javacpp Loader (and converts it so system-native format). I've been using a similar bit of code to locate the jar with my own code and write files to the same directory.

I can put the change in a pull request if you think it's a good modification.

@saudet saudet added the bug label Feb 24, 2015
@saudet
Copy link
Member

saudet commented Feb 24, 2015

Sounds good! Yes, please do send a pull request. Thanks!!

saudet added a commit that referenced this issue Feb 24, 2015
 * Clean up Windows `java.io.tmpdir` even when program messes with `java.class.path` (issue #12)
saudet added a commit that referenced this issue Feb 28, 2015
 * Provide `UByteIndexer` and `UShortIndexer`, treating array and buffer data as unsigned integers, for ease of use
 * Clean up Windows `java.io.tmpdir` even when program messes with `java.class.path` (issue #12)
@mabruce
Copy link
Contributor Author

mabruce commented Mar 27, 2015

Cleans up the temp files every time I've checked, so I'll mark this closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants