简体   繁体   中英

Export jar (eclipse) while keeping external lib and source files

I'm trying to export my java project to be able to send it to a company in order to find a job. I use Eclipse Mars.

I'd like to send them source files, the (.json) file my program works on, an executable jar and the external library i'm using (json-simple-1.1).

I've tried this technique Exporting a Java Project as .jar with including .java source code and preserving external libraries dependecies but it doesn't work for me, when I try to launch my project I get the following error

>>>java -jar projet.jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)

If you need more information, just ask me, I'll try to answer.

I'd like to apologize too because my question feels stupid... but I just can't find a solution...

Thank you in advance...

Create a folder inside your project (parallel to src ) and add all external libraries to it. Reference these libraries in your project (by adding them to build path).

Include them in your jar while exporting it with runnable jar. It should work.

Note: Never use external jar files using absolute path in your project. Always use relative path reference, so that the project works fine when shipped somewhere else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM