gpt4 book ai didi

java - 运行 java wsdl 客户端时出现无法找到主类错误

转载 作者:行者123 更新时间:2023-12-02 00:48:55 24 4
gpt4 key购买 nike

我编写了以下代码,它是 http://www.nanonull.com/TimeService/TimeService.asmx?WSDL 的客户端 wsdl :

package time;
class Client {
public static void main(String args[]){
TimeService service = new TimeService();
TimeServiceSoap port= service.getTimeServiceSoap();
String result = port.getTimeZoneTime("UTC+10");
System.out.println("Time is "+result);
}
}

但是当我尝试用 java 运行它时,我得到以下结果:

C:\Program Files\Java\jdk1.6.0_22\bin>java client.Client
Exception in thread "main" java.lang.NoClassDefFoundError: client/Client
Caused by: java.lang.ClassNotFoundException: client.Client
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: client.Client. Program will exit.

此错误是否意味着我应该导入任何类?

最佳答案

您编写的主类是time.Client,但您正在尝试运行client.Client。最好像这样运行:

java time.Client

如果这没有帮助,那么您遇到了类路径问题 - java 无法在类路径中找到主类。使用 -classpath option 设置类路径:

java -classpath classes-directory;list-of-jar-files time.Client

关于java - 运行 java wsdl 客户端时出现无法找到主类错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4007938/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com