【问题标题】:Unable to compile from ant but works from the command line, why?无法从 ant 编译但可以从命令行运行,为什么?
【发布时间】:2013-02-27 08:42:49
【问题描述】:

我无法在 ant 和 eclipse 中为我的项目提供一个类。

我正在使用 eclipse juno+wptant 1.7

我正在将委内瑞拉一家名为 CrediCard 的信用卡公司的支付平台集成到一个已经正常工作的网站。

我们收到了一个 .zip 包,其中包含以下内容:

我使用 debian 进行开发,因为银行指示我们需要一个名为的依赖项来编译和运行项目:

libc6.1-1.so.2

项目需要运行,我不太明白。 也因为生产操作系统也是非 debian。

该包有一个名为 ejemplodigest.java 的源示例,其中包含如下编译说明:

javac -classpath /home/DigestJavaLinux/classes ejemplodigest.java

然后像这样运行它:

java -Djava.library.path=/home/DigestJavaLinux/lib/ -classpath /home/DigestJavaLinux/:/home/DigestJavaLinux/classes ejemplodigest

这些命令在命令行上完美运行。要运行它,必须在 debian 中安装依赖项 libc6.1-1.so.2

当我在我的项目中包含相应的行并将类路径添加到 ant 的 javac 任务时,我什至无法用 ant 编译代码。我得到了错误

symbol  : class OasisEMSecIm
    [javac] location: class com.bamboo.catW3.business.impl.MainHtmlController
    [javac]          OasisEMSecIm digest= new OasisEMSecImp();

在类的声明和导入中:

import OasisEM.*;
import eMerchantServlet.*;

没有找到:

OasisEM does not exist.

这是给出的示例来源:

//import OasisEM.*;
import java.*;
// import eMerchantServlet.*;

class ejemplodigest {
    public static void main(String args[]) {
        String varMerchant = "00260364";        // Merchant ID
        String varStore = "0";                  // Store ID
        String varTerm = "4001";                // Term ID
        String varTotal = "12345445";           // Monto de Transaccion
        String varCurrency = "937";             // Codigo de Moneda
        String varOrder_id = "444444";          // Order Id
        String varDigest;                       // Valor de Digest


        OasisEMSecImp digest= new OasisEMSecImp();
        varDigest = digest.getDigest(varTotal,varOrder_id,varMerchant,varStore,varTerm,varCurrency);

        System.out.println ("Merchant ID :" + varMerchant);
        System.out.println ("Store ID :" + varStore);
        System.out.println ("Term ID :" + varTerm);
        System.out.println ("Total :" + varTotal);
        System.out.println ("Currency :" + varCurrency);
        System.out.println ("Order ID :" + varOrder_id);
        System.out.println ("Digest " + varDigest);

    }
}

我也无法让 Eclipse 识别它们,我尝试将类文件夹添加到 Eclipse 中,将类设为 jar 并添加它。

我检查了一下,ant任务正确接收了路径,所有其他依赖项都可以正常工作。

ANT 问题:为什么示例源代码使用命令行编译,但是当将相同的行添加到我的项目中的方法并将类路径添加到类文件夹时,它无法编译?

Eclipse 问题:如何让 Eclipse 识别 OasisEMSecImp 类?

更新

您好,ant 文件有点长,我将如何粘贴我认为相关的部分:

<path id="library.digest.classpath">
            <pathelement location="../../digest/classes"/>
        </path>

 <path id="catw.module.classpath">
        <path refid="library.blazeds.classpath"/>
        <path refid="library.hibernate3.classpath"/>
        <path refid="library.jta.classpath"/>
        <path refid="library.log4j.classpath"/>
        <path refid="library.mail.classpath"/>
        <path refid="library.oreilly.classpath"/>
        <path refid="library.spring-2.0.7.classpath"/>
        <path refid="library.velocity.classpath"/>
        <path refid="library.jexcel.classpath"/>
        <path refid="library.tomcat_5.classpath"/>
        <path refid="library.digest.classpath" />
        <pathelement location="../catw-common/build/catw-common.jar"/>
    </path>


<javac destdir="${catw.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true">
            <compilerarg line="${compiler.args.catw}"/>
            <bootclasspath refid="catw.module.bootclasspath"/>
            <classpath refid="catw.module.classpath"/>
            <src refid="catw.module.sourcepath"/>
            <patternset refid="excluded.from.compilation.catw"/>
        </javac>

我调试了catw.module.classpath,位置正确。

非常感谢您。

【问题讨论】:

  • 你好杰梅因。我相信我已经正确设置了类路径。我用新的类路径更新了问题。感谢您的帮助

标签: java eclipse ant payment-gateway


【解决方案1】:

我已经理解了这个问题并找到了解决我的情况的方法,我在我的answer in this question 中解释了它。

希望对某人有所帮助。

【讨论】:

    【解决方案2】:

    我认为您没有正确设置 ant 中的路径。您在路径元素中使用相对路径。因此,请确保您的项目的 basedir 设置正确。您可能还需要将 verbose 设置为 true 以获得一些有用的提示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-01
      • 2011-06-06
      • 1970-01-01
      • 1970-01-01
      • 2015-12-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多