我正在尝试制作一个控制台应用程序来测试我的Web服务。我成功地在http://localhost:8080/WS/myWS上部署了一个Web服务,并使用wsimport创建了代理类:
wsimport -d bin -s src http://localhost:8080/WS/myWS?wsdl
现在我的WebService类位于bin/myWebService/中,我正尝试用classpath = ./编译我的客户端类
下面是我的类的源代码:
import bin.mywebservice.myClass_Service;
public class TesterApp{
public static void main (String args[])
{
myClass_Service service = new myClass_Service();
}
}
我有错误:
TesterApp.java:1: error: cannot access myClass_Service
import bin.mywebservice_Service.myClass;
^
bad class file: .\bin\mywebservice\myClass_Service.class
class file contains wrong class: mywebservice.myClass_Service
Please remove or make sure it appears in the correct subdirectory of the classpath.
请帮助,myClass_Service有什么问题?我发誓myClass_Service.class存在于.\bin\mywebservice\
4条答案
按热度按时间cgh8pdjw1#
您错误地将
bin
包含在import
声明中。而是将
bin
放在类路径上并更正import
。除非(名称不好的)
myClass_Service.java
文件是package bin.mywebservice
(根据错误信息,它不是),否则您试图在错误的地方纠正问题。fdx2calv2#
看起来生成的类有一个包
mywebservice
,而不是bin.mywebservice
。确保bin
目录在类路径上,并从包中删除bin
。eqoofvh93#
如果你确定你的文件位于
bin
目录下,你已经检查了调用mywebservice.myClass_Service
的类文件在
bin
目录下也一样。因为当两个文件的位置不一样时,就会出错。或者您可以在代码顶部查看您的包裹位置。Package 箱;
看看并比较这两个。
tv6aics14#
如果您正在使用软件包,此makefile可能会有所帮助: