在Eclipse中运行和转到项目文件夹并使用.jar之间的区别

时间:2018-06-01 10:26:09

标签: java eclipse

我试图找到有关eclipse如何处理运行项目的更多信息。 我想更多地了解它,因为我有一个问题,我目前正在使用apache-poi .jar文件,当项目通过eclipse运行时,已经包含在项目类路径中的文件将正常运行,但是转到相同的项目文件夹并运行主jar文件以启动程序时,将无法检测到

它给了我错误:java.lang.NoClassDefFoundError:org/apache/poi/ss/usermodel/Cell(虽然有时候代替Cell,它的工作表)

我可以咨询一下,了解这里发生了什么,并可能解决这个问题?

1 个答案:

答案 0 :(得分:0)

Your NoClassDefFoundError indicates that the library was not available while running the jar.

This depends upon how you are exporting your project into the jar file.

If you're using eclipse to do so, you can:

Export->Java->Runnable Jar to create a jar that includes its dependencies

Make sure to check Package required libraries into generated JAR.

This will make all your jars (in build path including apache-poi.jar) as a part of the final jar.

It runs from eclipse because libraries are on the build path of the eclipse which makes them available in the classpath.