简体   繁体   中英

Eclipse export .jar with referenced libraries

I've added a few libraries to my project as external jars, one being HikariCP ( https://github.com/brettwooldridge/HikariCP ) however when I run my jar I'm given these errors

java.lang.NoClassDefFoundError: com/zaxxer/hikari/HikariDataSource

and

Caused by: java.lang.ClassNotFoundException: com.zaxxer.hikari.HikariDataSource

I've tried to bundle these libraries by exporting the project as a "Runnable Jar file" and ticked "Package required libraries into generated jar", however the same errors still persist.

I don't currently have my project set up with Maven, as I've never had the reason to use it (until now?) I've heard this is easy to accomplish via Maven however I was wondering if there's another workaround without it.

Try running after including .classpath file in the jar file. You can include the .classpath file from the jardesc in eclipse.

Unpack libs. Next Alt-Enter => Java Build Path => Libraries => 1. Remove packed library 2. Click "Add External Class Folder" 3. Select your folder with library(-es) 4. Click OK 5. Enjoy :)

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