0

Using JSoup for html scraping, I'm attempting to compile my jarfile so that I may run this off Eclipse. As seen here: (http://i.imgur.com/hLmeQ.jpg), my jsoup jarfile is added to the external libraries. However, upon running the program I get a NoClassDefFoundError. This is insinuative that it's not finding the classfiles, so I decompiled and double-checked: The class files were within the imported jar. The manifest file is correct too.

I'm running: Eclipse: Build id: 20110916-0149, Java 7 update 5 (64 bit), and jsoup 1.6.3,

And I am not compiling using Maven.

4

2 回答 2

0

找不到该类,因为:

您的 Class-Path 声明是Class-Path: jsoup-1.6.3.jar,但是从您的屏幕截图中,jsoup-1.6.3.jar是 in c:\Users\Amber\Desktop\New Folder,因此除非您从同一文件夹运行 JAR 文件,否则将找不到它。

解决方案:

  1. 运行你的 JARc:\Users\Amber\Desktop\New Folder
  2. - 或 - 复制jsoup-1.6.3.jar到与您的 JAR 相同的文件夹
  3. - 或 - 为所有库(如 c:\java\libs)提供一个公共文件夹,并将此文件夹包含在 CLASSPATH 系统环境变量中
于 2012-07-23T00:42:09.707 回答
0

你说:

清单文件也是正确的。

但是你确定吗?实际上,您的 jar 文件的清单是什么样的?它应该看起来像:

Manifest-Version: 1.0
Main-Class: yourMainClassPackage.YourMainClass
Class-Path: jsoup-1.6.3.jar

您确定您的 jsoup jar 文件相对于清单中的路径规范位于正确的位置吗?

于 2012-07-22T16:08:28.720 回答