aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes classpah in readme Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "classpah in readme" Watch "classpah in readme" New topic
Author

classpah in readme

hao li
Greenhorn

Joined: Jul 24, 2002
Posts: 21
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

Joined: Jan 30, 2002
Posts: 3451
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


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
hao li
Greenhorn

Joined: Jul 24, 2002
Posts: 21
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

Joined: Oct 08, 2001
Posts: 2937
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

Joined: Jul 24, 2002
Posts: 21
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

Joined: Jul 24, 2002
Posts: 21
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

Joined: Jan 30, 2002
Posts: 3451
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

Joined: Oct 15, 2001
Posts: 101
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

Joined: Jan 30, 2002
Posts: 3451
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

Joined: Oct 15, 2001
Posts: 101
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

Joined: Jan 30, 2002
Posts: 3451
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: classpah in readme