This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classpah in readme

 
hao li
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
the instruction say that:
For example, do not say
something like "add server.jar to your classpath". You should document exactly how to add the jar file to the classpath.
But for my case,after I made client.jar and server.jar, I dont need to setup classpath.
all I need to do is that:
java -jar server.jar portNumber ...
or
java -jar client.jar ...
It works fine.
Am I wrong?
Thank you for your replay.
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hao,

It works fine.
Am I wrong?

Nope. That's exactly what you want. No environmental setup at all. As long as both client and server will run from any directory without setting the CLASSPATH, that's good enough.
Michael Morris
 
hao li
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your replay,
You said:
No environmental setup at all
but before I run server, I should setup:
start rmiregistry
Is it right or this command can merge into code?
Thanks,
 
John Smith
Ranch Hand
Posts: 2937
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it right or this command can merge into code?

Yes, you can start registry from the code, and many of us chose to do it that way. Look at
LocateRegistry.createRegistry(port) and LocateRegistry.getRegistry(port) in API.
Eugene.
 
hao li
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to use the following code
if (LocateRegistry.getRegistry(port) == null){LocateRegistry.createRegistry(port);
}
in the server to replace start rmiregistry command.
How can I start my server without use rmiregistry? please help.
 
hao li
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to use the following code
if (LocateRegistry.getRegistry(port) == null){ LocateRegistry.createRegistry(port);
}
in the server to replace start rmiregistry command. but it is failed.
How can I start my server without using rmiregistry? please help.
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hao,

if (LocateRegistry.getRegistry(port) == null){ LocateRegistry.createRegistry(port);
}

Don't make it conditional. Just call LocateRegistry.createRegistry(port); Note that LocateRegistry.getRegistry(port) will never return null, but it may return a bogus Registry. Here is an excerpt from LocateRegistry's javadoc:

Note that a getRegistry call does not actually make a connection to the remote host. It simply creates a local reference to the remote registry and will succeed even if no registry is running on the remote host. Therefore, a subsequent method invocation to a remote registry returned as a result of this method may fail.
Hope this helps,
Michael Morris
 
christy smile
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think I am a little confused. Even though you only need
>java -jar client.jar
to start the client application, don't you still have to make sure that client.jar is on the classpath. What if the user starts the application from a totally different directory than the root directory of your application?
Please clarify this for me! Thank you very much!
Christy
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christy,

... What if the user starts the application from a totally different directory than the root directory of your application?

Then he would not be following your command line which gives no provision for starting in a different directory. It is safe to assume that the assessor will start your application in the same directory as your executable jars.
Michael Morris
 
christy smile
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Michael,
Thank you for the reply. That's convincing. But in my UserGuide, I still put add the jar to the classpath first, is that okay, or it is just too redundant?
thanks.
BTW, I read from a post (http://www.coderanch.com/t/182049/java-developer-SCJD/certification/Fine-line-between-controller-mediator) referring to your discussion of the Mediator pattern, could you give me a pointer to that post, since I could not find it.
Christy
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christy,

Thank you for the reply. That's convincing. But in my UserGuide, I still put add the jar to the classpath first, is that okay, or it is just too redundant?

The problem is that the instructions say:
... If any environmental setup is required, do not just say what needs to be done; provide instructions on how to perform the setup. For example, do not say something like "add server.jar to your classpath". You should document exactly how to add the jar file to the classpath.
Now, given that, how do you document exactly how to add the jar file to the classpath. Do you say on Windows 2000 Pro do this, on Windows 98 do this, on Linux Mandrake do this, on Solaris do this; well you get the point. Why risk failing on a techincallity if you can just let sleeping dogs lie?
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic