I am reading this book to learn about web services. How do I compile the exercise given in chapter 1.
Appreciate a reply.
in cmd do i go to eac directory and compile and execute the code.

Really appreciate a reply

in cmd you navigate to whatever directory you have your .java files in.

to compile a specific file with name Name.java, in cmd you type the following (without quotes):

"javac Name.java"

to run the program, you type:

"java Name"

however, you need to have your environment variables set well so that your computer knows where javac.exe and java.exe may be found. ALSO, you CANNOT run a java class that does not contain a main method...

to do that, you navigate to ...program files/java/bin and copy that complete path into your "path" environment variable, without deleting its current content (lest you do that like a friend once did :) LOL). there are variations of this, but basically path variable needs to know where java.exe and javac.exe are.

this information is readily available if you search online.

let me know if you need more help.

you are reading "this book"? hmmm ...
let me just see if I have "this book" available right here.
if that book is any decent all you need to know is either explained in there, or is listed as requirement before starting with it. most likely, it's explained, since getting your webservices up and running is kind off a big part of it all.


ALSO, you CANNOT run a java class that does not contain a main method...

he is not trying to 'run a java class', he is trying to compile and run deploy a webservice.
if he's working with a webapp, why would he need a main method?

:( as I was writing the message, I could see the OP frowning upon a little over asumptious message of mine, but I now see I was assuming a little more than I recognized initially. Otherwise, I have gone through the first chapters of the book and I remember I have published services, but I have to admit that I do not remember how the publishing goes.

it is easy to come off wrong when challenging someone, but please do not get me wrong.
I just checked online, and I think publshing a web service actually does make use of a main method.

The following is taken from the book:

public class TimeServerPublisher {
    public static void main(String[ ] args) {
      // 1st argument is the publication URL
      // 2nd argument is an SIB instance
      Endpoint.publish("", new TimeServerImpl());

I guess the op needs to java TimeServerPublisher in one cmd instance, and do the rest in another cmd or some other form, perhaps a web interface. Is there anything I am missing?

it all depends on your application.
for instance, if you are working with GWT and webservices, or with the JSP/Servlets combo with webservices ... they're all Java applications, yet none 'll have a main method. (well, the could have one, but they just won't serve as the entrypoint of the application)