tags:

views:

36

answers:

2

I have written the following code, which is meant to be a client wsdl for http://www.nanonull.com/TimeService/TimeService.asmx?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);
 }
}

But when I try to run it with java I get the following:

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.

Does this error mean I should be importing any classes?

+1  A: 

You need to set the classpath:

C:\Program Files\Java\jdk1.6.0_22\bin>java -cp . client.Client
Darin Dimitrov
Thanks but I still get the same error with the -cp .
homiejoe
+1  A: 

The main class you wrote is time.Client, but you are trying to run client.Client. Better run it like this:

java time.Client

If this does not help, then you have a classpath problem - java cannot find the main class in the classpath. Set the classpath with -classpath option:

java -classpath classes-directory;list-of-jar-files time.Client
Neeme Praks
java time.Client was the issue
homiejoe
how about accepting my answer then? ;-) http://stackoverflow.com/faq#howtoask
Neeme Praks