简体   繁体   中英

java.lang.ClassNotFoundException in runnable jar exported by Eclipse

I am using Eclipse to export my project into a runnable jar.

I'm using a few libraries, namely Apache commons, Java FX, and GSON.

I have added those libraries to my Build Path inside Eclipse: Eclipse Java构建路径的屏幕截图

When exporting, I choose to package the required libraries into the generated jar: Eclipse导出到可运行jar的屏幕截图 This creates a jar called Editor.jar

However when I do "java -jar Editor.jar" I get the java.lang.ClassNotFoundException for the class EqualsBuilder which is a part of Apache commons.

I've tried copying the apache commons-lang3-3.4.jar file into the working directory. I've also tried adding "-cp commons-lang3-3.4.jar" before the "-jar". Still I always get the ClassNotFoundException.

Does anyone see what I'm missing? Thanks.

Select that option while exporting , If u dont select that option then u might have to resolve the dependencies on your own using -cp

在此处输入图片说明

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