I have a program which copies files from itself (inside the .jar) outside, but whenever I try to run it from Eclipse, it gives me an exception:
java.io.FileNotFoundException: <my workspace>\<my project>\bin (Access is denied)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
I’m guessing this is because Eclipse doesn’t make a .jar every time you run. I can run my program perfectly by exporting the runnable jar, but it’s tedious and painful to export every time I want to test the program.
Is there any way you can tell Eclipse to make a .jar every time it runs (I know it will be slow, but that’s fine). Or at least emulate a jar file?
@Salain is right – but if your use case is just copying files outside of your project, wouldn’t it be easier to ignore whether they’re in a jar or not, and just get a handle on them via
YourClass.class.getResourceAsStream("/path/to/file")?