JAVA EE& Eclipse:即使我已经设置了构建路径,我也得到了java.lang.NoClassDefFoundError

时间:2014-03-01 17:43:58

标签: eclipse java-ee java

我正在使用Eclipse和Google App Engine插件。我正在尝试运行一个添加了joda时间的简单程序。似乎错误与构建路径有关,我按照以下说明操作: https://stackoverflow.com/a/12105417/3255963 但我仍然得到以下错误。接下来我需要做什么?

package test;
import java.io.IOException;
import javax.servlet.http.*;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

@SuppressWarnings("serial")
public class testServlet extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

        DateTime newYears = new DateTime (2014, 1, 1, 0, 0);

        resp.setContentType("text/plain");
        resp.getWriter().println("Hello, world");

    }

}       

错误:

java.lang.NoClassDefFoundError: org/joda/time/DateTime

我在项目资源管理器和构建路径中看到了joda-time-2.3.jar。

我也尝试在订单和导出下选择它。

1 个答案:

答案 0 :(得分:2)

当Java虚拟机无法在运行时找到编译时可用的特定类时,Java中会出现NoClassDefFoundError。 请知道你是否有需求。项目浏览器中的\ WebContent \ WEB-INF \ lib下的jar以及项目构建路径。