导出到jar后的eclipse项目不起作用

时间:2023-01-17 13:11:18

I have 2 project in my eclipse work_space. Project A:Source of Apache Tomcat by a little edit[and have some dependent jars]. Project B: A small project call one method[One method of project A's methods].

我的eclipse work_space中有2个项目。项目A:通过一点编辑[并且有一些依赖的jar]的Apache Tomcat的源代码。项目B:一个小项目调用一种方法[项目A方法的一种方法]。

So when I used Project A in Project B(added to BuildPAth's projects) or test this method in project A that work. But When project B used exported project A's jar file DOESN'T Work(only remove project A from project B's BuildPath and add A's jar file). Exception which throw is:

因此,当我在项目B中使用项目A(添加到BuildPAth的项目中)或在项目A中测试此方法时可行。但是当项目B使用导出的项目A的jar文件时不能工作(只从项目B的BuildPath中删除项目A并添加A的jar文件)。抛出的异常是:

   Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/util/FileUtils
    at org.apache.jasper.JspC.resolveFile(JspC.java:1602)
    at org.apache.jasper.JspC.setOutputDir(JspC.java:863)
    at org.apache.jasper.JspC.setArgs(JspC.java:276)
    at org.apache.jasper.JspC.main(JspC.java:241)
    at jspCompiler.pars(jspCompiler.java:65)
    at jspCompiler.main(jspCompiler.java:100)
    at maintst.main(maintst.java:11)
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.util.FileUtils
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 7 more

Where is problem?

哪里有问题?

EDIT

Maintst.java

import jspParser.jspCompiler;
public class maintst { 
  public static void main(String[] args) throws Exception { 
    jspCompiler cmp=new jspCompiler();
    cmp.main(new String[]{"F:\\arshad droos\\Thesis\\secureBranch\\personalblog\\build","F:\\arshad droos\\Thesis\\secureBranch"}); 
  }
}

2 个解决方案

#1


0  

Browsing the code of Apache Tomcat i could not find the find org.apache.tools.ant.util.FileUtils. Since running from eclipse works, this probably means is that Project A has some jar in the build path which has this file. Find it, put in in the build path of Project B and things should work.

浏览Apache Tomcat的代码我找不到find org.apache.tools.ant.util.FileUtils。由于从eclipse运行,这可能意味着项目A在构建路径中有一些具有此文件的jar。找到它,放入项目B的构建路径中,事情应该有效。

#2


0  

Eclipse has a fatjar named plugin. After installing this jar to eclipse plugins(Copy past jar file to eclipse's plugin directory) In Export menu select jar fat. In this way size of exported jar is big But Standalone.

Eclipse有一个名为plugin的fatjar。将此jar安装到eclipse插件后(将jar文件复制到eclipse的插件目录)在Export菜单中选择jar fat。这样导出的jar的大小很大但是Standalone。

Thank you.

#1


0  

Browsing the code of Apache Tomcat i could not find the find org.apache.tools.ant.util.FileUtils. Since running from eclipse works, this probably means is that Project A has some jar in the build path which has this file. Find it, put in in the build path of Project B and things should work.

浏览Apache Tomcat的代码我找不到find org.apache.tools.ant.util.FileUtils。由于从eclipse运行,这可能意味着项目A在构建路径中有一些具有此文件的jar。找到它,放入项目B的构建路径中,事情应该有效。

#2


0  

Eclipse has a fatjar named plugin. After installing this jar to eclipse plugins(Copy past jar file to eclipse's plugin directory) In Export menu select jar fat. In this way size of exported jar is big But Standalone.

Eclipse有一个名为plugin的fatjar。将此jar安装到eclipse插件后(将jar文件复制到eclipse的插件目录)在Export菜单中选择jar fat。这样导出的jar的大小很大但是Standalone。

Thank you.