Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI class loading

 
Hugh Johns
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have implemented RMI and tested it for simulated remote network use on a single machine (using localhost as IP).
I want to complete the testing of this section by placing the test client on another machine. I have Java j2se installed on the second machine, but am unsure as to ...
which classes are required on the client m/c,
what directory structure they should be in on the client m/c,
If the RMI registering has to be done manually on the server, before the client can access the remote methods.
If someone could describe the process it would be appreciated.
Thanks
Hugh
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hugh,
Originally posted by Hugh Johns:
[QB]
1) which classes are required on the client m/c,
2) what directory structure they should be in on the client m/c,
3) If the RMI registering has to be done manually on the server, before the client can access the remote methods.

How are you testing the client-server on the same machine? Are you running the server ("java -jar runme.jar server") in one command prompt, and running the client ("java -jar runme.jar") in another command prompt? If so then running on two different machines is easy. Keep the server running on one machine. Start the client running on another machine, configure it to use the database server host. That's it.
Of course, this assumes that you're starting the RMI registry programmatically (rather than manually). For suggestions on how to do that see: Topic: RMI Binding on localhost
Now, to get back to your questions:
1) basically the same classes as on the server (this is a non-issue if all your classes are in the runme.jar)
2) again, a non-issue if all your classes are in the runme.jar
3) it is possible to start the RMI registry from the command-line, but it's a non-issue if you do it programmatically from your runme.jar
So, the answer to your questions really boils down to using a runme.jar.
 
Anna Hays
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So does the client suppose to get the same jar file when they run the application?
I.e. the same runme.jar is use by the server machine AND the client machine?
I am having trouble of understanding how to distribute the code to clients. If the runme.jar file is to be on the client machine, that would mean they can start they own RMI server.
Am I even on the right track???
Sorry I didn't mean to steal your post with my own quesion, but I think I have the exact same questions
[ March 03, 2004: Message edited by: Anna Kafei ]
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anna,
Originally posted by Anna Kafei:
So does the client suppose to get the same jar file when they run the application?

Yes.

I.e. the same runme.jar is use by the server machine AND the client machine?

Yes.

I am having trouble of understanding how to distribute the code to clients. If the runme.jar file is to be on the client machine, that would mean they can start they own RMI server.

Distributing the code is a simple as distributing the runme.jar since it contains all the *.class files. If the runme.jar file is to be on the client machine then why couldn't it start it's own RMI server? Well it could, but presumably it doesn't because it wants to access a database file on another machine (the server machine). There's no requirement that a database file exist on a machine that wants to run the application in the network client mode. Whereas, any machine that wants to run the application in either standalone mode or server mode should have a local database file.

Am I even on the right track???

Yes, you are absolutely on the right track. All the *.class files are in a single jar file, runme.jar, so distributing the code is as simple as distributing the runme.jar file.
The application runs in one of three operating modes: standalone, server, and network client. The simplest case is standalone mode, wherein the application is started by "java -jar runme.jar alone" and accesses a database file on the same machine. The server-client case is as follows: on the server machine the application is started by "java -jar runme.jar server" and accesses a database file on the server machine, on the client machine the application is started by "java -jar runme.jar" and accesses the database server running on the server machine. Although a bit unusual the server machine and client machine can be the same machine. In this case the server is started on a machine and the client is started on the same machine (this configuration is useful if you're constrained to testing on a single computer).
 
Anna Hays
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you George!! I think I have to stop thinking I am developing a real software. Cos I kept thinking, 'Oh, what if the client decompiles my code and hack my server', things like that and complicate the issue and worry about things that are totally out of the scope.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic