java“类文件包含错误的类";错误 [英] java "Class file contains wrong class" error

查看:305
本文介绍了java“类文件包含错误的类";错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个控制台应用程序来测试我的Web服务. 我已在 http://localhost:8080/WS/myWS 上成功部署了Web服务. 我用wsimport制作了代理类:

I'm trying to make a console application to test my webservice. I successfully deployed a webservice at http://localhost:8080/WS/myWS and i made proxy classes with wsimport:

wsimport -d bin -s src http://localhost:8080/WS/myWS?wsdl

现在,我的Web服务类位于bin/mywebservice/中,我正在尝试使用classpath = ./

Now my webservice classes are located in bin/mywebservice/ and i'm trying to compile my client class with 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 \

please help, what's wrong with myClass_Service? i swear, myClass_Service.class exists in .\bin\mywebservice\

推荐答案

您在import声明中错误地包含了bin.

You're incorrectly including the bin in the import declaration.

相反,将bin放在类路径上,然后更正import.

Rather put bin on the classpath and correct the import.

除非(错误命名的)myClass_Service.java文件是package bin.mywebservice(根据错误消息,不是),否则您试图在错误的位置纠正问题.

Unless (the poorly-named) myClass_Service.java file is package bin.mywebservice (which it isn't, according the the error message), you're trying to correct the problem in the wrong place.

这篇关于java“类文件包含错误的类";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆