Hey ya'll, this is my first post here.
I'm working on an exercise from O'Reily's Learning
Java concerning web services implemented with JAX-WS. It's my understanding that JAX-WS ships with the Java 7 JDK package. It's also my understanding that classes implementing annotation and importing the jws API deploy from their own mini-server, without the need for, say,
Tomcat or GlassFish. I have the class packaged, per the instructions in the exercise, in a directory called learningjava, in a subdirectory called service. This path lives in my main user directory. I attempt to run the compiled class from the command line thus:
C:\Users\montypadre\learningjava\service>java Echo
This is the response I get:
Exception in
thread "main" java.lang.NoClassDefFoundError: Echo (wrong name: learningjava/service/Echo)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.lang.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
This is my classpath, set in the system environment variables:
%JAVA_HOME%\bin;.;%JAVA_HOME%\jre\lib\rt.jar;.;%JAVA_HOME%\lib\tools.jar;.;%CATALINA_HOME%\lib\servlet-api.jar;.;%ANT_HOME%\bin\ant.bat;.
%JAVA_HOME% is C:\Program Files\Java\jdk1.7.0_51
The path, also in the system environment variables:
%JAVA_HOME%\bin;.;%ANT_HOME%/bin;
And finally, this is the code for the class itself:
package learningjava.service;
import javax.jws.*;
import javax.xml.ws.Endpoint;
@WebService()
public class Echo
{
@WebMethod()
public int echoInt( int value ) { return value; }
@WebMethod()
public
String echoString( String value ) { return value; }
@WebMethod()
public MyObject echoMyObject( MyObject value ) { return value; }
public static void main( String[] args )
{
Endpoint endpoint = Endpoint.publish( "http://localhost:8080/echo",
new Echo() );
}
}
class MyObject
{
int intValue;
String stringValue;
public MyObject() { }
public MyObject( int i, String s ) {
this.intValue = i;
this.stringValue = s;
}
public int getIntValue() { return intValue; }
public void setIntValue( int intValue ) { this.intValue = intValue; }
public String getStringValue() {
return stringValue;
}
public void setStringValue( String stringValue ) {
this.stringValue = stringValue;
}
}
Any help I can get would be awesome, greatly appreciated. Thanks for ya'lls attention.