-1

I do tutorial in following link: Java RMI Tutorial

After I compile successfully three files (interface, server and client) by hand, appear three classes in same folder. Then, I do like what tutorial say:

1) Start RMI server: start rmiregistry a new blank dos screen appear (maybe server is running, right ? )

2) Start server: start java -classpath classDir example.hello.Server: a flash dos screen appear (it so fast that I cannot see what they said !!!). But, at that site, they say, in command prompt will ouput Server ready. But, I don't see (something wrong ?)

3) Start Client: java -classpath classDir example.hello.Client: a long list of parameters appear like I missing something, but it doesn't say what I'm missing.

Please help me run this example.

Thanks :)

Edit: here is notice (if I run server and client without start command)

Error

4
  • Are you substituting classpath with your real classpath? Run the server command without start and you will be able to see the errors occurring for it. Post both the server and client errors in your question.
    – Perception
    Apr 8, 2012 at 11:45
  • @Perception I have edited my post. Please watch it for me. Thanks :)
    – hqt
    Apr 8, 2012 at 11:55
  • Oh. I don't know why my post have a minus point :( I really help for my problem
    – hqt
    Apr 8, 2012 at 12:01
  • where classDir is the root directory of the class file tree => Replace the classDir with the correct directory, Iguess . in your case.
    – JiP
    Apr 8, 2012 at 12:08

1 Answer 1

2

When the tutorial says that you should run your server with

start java -classpath classDir example.hello.Server

It (erronously in this case) assumes you know you should replace classDir with your actual classpath. The command should look something more like this:

start java -classpath "." example.hello.Server

Assuming that all your classes are rooted relative to the directory you are running your commands from. As it is, you are omitting the classpath altogether, which causes the JVM to gobble your classname and interpret it as the classpath instead:

java -classpath Server

If you do not know how to determine and set your classpath then I will definitely recommend you start with more basic tutorials, instead of jumping straight into RMI.

3
  • classpath: (in Windows), is set Path in Windows Evironment, right ;) If that true, I don't think it's my problem !!! Yes, as you said, I start command from example.hello. So, I just type: java-classpath Server. And, error as I said. Please tell me how to fix it.And I typing classdir just I copy from that website, not I copy it to command prompt !!!
    – hqt
    Apr 8, 2012 at 12:15
  • I have compile java file by hand multi times, but just single file (it mean each file doesn't depend of other) and it just a pure java class, I have never done this work (create server,etc) before.
    – hqt
    Apr 8, 2012 at 12:16
  • There is no difference in compiling and running the 'server' from compiling and running a regular Java program. If you think your classpath is appropriately set in Windows, then leave out the -classpath option. Just keep in mind that it's best practice not too rely on the environment classpath when compiling/running your programs. Try this to start: java -classpath %CLASSPATH% example.hello.Server
    – Perception
    Apr 8, 2012 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.