2013-05-20 33 views
0

我從愛馬仕(hermes2_src_20100121)得到的源代碼。當我提取它有大約10個文件夾,這是不同的項目。類路徑不工作

/myd1/Exetel/Hermes_SRC/ebxml-pkg 
/myd1/Exetel/Hermes_SRC/CorvusEbMS 
/myd1/Exetel/Hermes_SRC/Commons 
Etc…. 

Each project has its own build script 
/myd1/Exetel/Hermes_SRC/ebxml-pkg/ant/build.xml 
/myd1/Exetel/Hermes_SRC/CorvusEbMS/ant/build.xml 
/myd1/Exetel/Hermes_SRC/Commons/ant/build.xml 
Etc…. 

我需要使用給定的Ant腳本 當我運行該腳本構建失敗,這個10個項目,並讓編譯錯誤 /myd1/Exetel/Hermes_SRC/ebXML的-PKG/src目錄/香港/香港大學/ cecid/ebms/pkg/PKISignatureImpl.java:98:error:package org.apache.log4j does not exist etc .....

問題在這裏,找不到log4j(類似dom4J,Mail, etc ..)

所以我在路徑「/ myd1/exete/libs /」中創建了文件夾,並在那裏添加了所需的jar文件並設置了CLASSPA TH到這個文件夾

CLASSPATH=/myd1/exete/libs/* 

但仍給出了同樣的錯誤的路徑並不工作

我嘗試添加CLASSPATH到〜/ .bashhrc

CLASSPATH=/myd1/exete/libs/* 
Export CLASSPATH 

添加到CLASSPATH gedit中的/ etc /環境 Env | grep的CLASSPATH打印正確的路徑

的問題是,當我運行構建腳本它仍然給出了同樣的錯誤的路徑並不工作

回答

0

你應該Ant腳本或者設置CLASSPATH:

<path id="common.classpath"> 
    <fileset dir="/myd1/exete/libs"> 
     <include name="*.jar"/> 
    </fileset> 
</path> 

根據http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/classpath.html設置CLASSPATH

classpath1:classpath2 Class paths to the .jar, .zip or .class files. Each classpath should end with a filename or directory depending on what you are setting the class path to: For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file. For .class files in an unnamed package, the class path ends with the directory that contains the .class files. For .class files in a named package, the class path ends with the directory that contains the "root" package (the first package in the full package name). Multiple path entries are separated by colons.

The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.

Classpath entries that are neither directories nor archives (.zip or .jar files) nor * are ignored.

所以,你應該嘗試之一:

CLASSPATH=/myd1/exete/libs/* 
or 
CLASSPATH=/myd1/exete/libs 
0

設置CLASSPATH爲CLASSPATH=/myd1/exete/libs/myjar.jar

即命名在CLASSPATH的罐子!