0

my project reads a certain format of xml files and exports them on xls.

When I run the project through netbeans or eclipse, it runs without a problem, but when I export it in a jar (containing my external libraries in the case of eclipse) it throws an ioexception. The application starts normaly though and do not crush, it just seem not able to use the classes of poi-3.16.jar and (or) commons-codec-1.10 i suppose. Thank you in advance for your help!

jim93m
  • 1
  • 1
  • 2
    You have to include all the dependencies in your jar. Is a maven project? In this case https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven – Davide Patti Sep 07 '17 at 14:47
  • No it is not a maven project, i do not know how to use maven yet. Should i study it in order to make my aplication to run correctly? – jim93m Sep 07 '17 at 14:54
  • When you are exporting as JAR are you including the dependent JARs too? – Soumya Sep 07 '17 at 14:55
  • yes, I do include the JARs. In the case of Eclipse they are packed in one single Jar. In the case of Netbeans they are stored inside the project folder and the clean build copies them in a lib folder inside the dist folder. – jim93m Sep 07 '17 at 15:00
  • @jim93m Isn't necessary. I think here there is a solution for you https://stackoverflow.com/questions/25113692/create-executable-jar-file-under-eclipse – Davide Patti Sep 07 '17 at 15:08
  • Yes Druden that's how i have created my project jar on eclipse, thank you though for your help. – jim93m Sep 07 '17 at 15:24
  • 1
    So much senseless comments, but if "it throws an ioexception": Please show the stacktrace. – Axel Richter Sep 07 '17 at 15:35
  • As i said Axel, the program runs without a problem inside the ide. So the stack trace is clear. I know that it throws an ioexception because i added some code to the catch section of the ioexception hadling. – jim93m Sep 07 '17 at 17:07
  • 1
    So do `... catch(IOException ioe) { ioe.printStackTrace(); }` and show what it prints. Or print the stacktrace to any other stream using [printStackTrace(PrintStream s)](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#printStackTrace-java.io.PrintStream-) if you don't have access to `System.err`. – Axel Richter Sep 07 '17 at 17:35
  • Axel you are the best! I did n't know that i can print the stack trace outside of an ide. I did printed it to a file and solved the problem which was an image file that was not save inside the jar but inside the project. That's why eclipse could run it, but the jar could n't. Thank you very much for your help! – jim93m Sep 08 '17 at 09:58
  • @jim93m: You are welcome. This is exactly the reason why I always avoid even to mention a IDE in programming courses until the course mates are able to do all the things without a IDE. Same for maven etc. until they really understood dependencies and the needed steps in developing software. – Axel Richter Sep 08 '17 at 13:04

0 Answers0