Search code examples
javarmi

RMI Client and Server programms


I implemented a client and server programms using RMI. I wrote this both server and client classes in same project. But now I want to run this client and server programms separately (as two projects). So how can I do this?


Solution

  • Split your application into three artifacts/projects/JARs:

    • client - code that calls the server via RMI API. Depends on api
    • server - implement the API on the server side. Obviously client is not dependent on this artifact
    • api - both client and server depend on API: client uses, server implements.

    This approach allows you to develop both client and server independently. Also changing the api can't easily be missed since it is a separate project.