2012-11-02 63 views
1

我想编译一个简单的SOAP客户端的例子与Axis2一起交付。但是Java编译器找不到进口:公理类无法找到

import org.apache.axiom.om.OMAbstractFactory; 
import org.apache.axiom.om.OMElement; 
import org.apache.axiom.om.OMFactory; 
import org.apache.axiom.om.OMNamespace; 
import org.apache.axis2.AxisFault; 
import org.apache.axis2.addressing.EndpointReference; 
import org.apache.axis2.client.Options; 
import org.apache.axis2.client.ServiceClient; 

我检查我的CLASSPATH变量是跟上时代的在命令行上,它包括:

C:\axis2-1.6.1\lib 

我还检查lib目录包含所需的Axiom罐(它确实)

axiom-api-1.2.12 
axiom-dom-1.2.12 
axiom-impl-1.2.12 

而且这些罐子与我正在导入的包装相匹配。我怎么能仍然得到错误:

error: package org.apache.axiom.om does not exist 

+0

没有classpath中只包含* LIB *目录,或包含在所有的jarfiles中? –

+0

只有lib目录,但jar文件位于lib目录的根目录以及随Axis2一起提供的其他jar文件中。 – Jack

+1

如果您在类路径中放置了一个以目录结尾的路径,则它只会在那里搜索类文件;您需要列出单个jar文件,或使用通配符,如“C:\ axis2-1.6.1 \ lib \\ * ;.”。 http://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html –

回答

2

Asix2 User Guide描述的目录结构和使用Axis2的工具,以防止需要设置CLASSPATH环境变量:

The bin directory includes a number of useful scripts. They include axis2.bat (or axis2.sh), which enables you to easily execute a Java command without having to manually add all the Axis2 jar files to the classpath