Skip to content

Instantly share code, notes, and snippets.

@hinerm
Created June 18, 2015 18:14
Show Gist options
  • Save hinerm/ac02be7beacaa1a065b3 to your computer and use it in GitHub Desktop.
Save hinerm/ac02be7beacaa1a065b3 to your computer and use it in GitHub Desktop.
Test the ability of a jar to overwrite itself
package org.scijava;
import java.io.FileOutputStream;
import java.io.IOException;
public class Main {
public static void main(String... args) throws IOException {
//FIXME: set this path to the location of the jar containing this main class.
String url = "C:/Users/Johannes/loci/test/target/scijava-tests-2.43.1-SNAPSHOT.jar";
FileOutputStream output = new FileOutputStream(url, false);
for (int i=0; i<100000; i++) {
output.write(0);
}
output.close();
}
}
@ctrueden
Copy link

So, to be clear: this works! On Windows. No file locking issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment