Skip to content

Latest commit

 

History

History
101 lines (92 loc) · 2.65 KB

README.md

File metadata and controls

101 lines (92 loc) · 2.65 KB

LibraryServer

Java RMI practice


RMIBasic

The basic RMI practice

How to run?

server side

  • Place ComputingService.java, ComputingServiceImpl.java and RMIServer.java in the server.
  • use javac to compile them
    javac ComputingService.java
    javac ComputingServiceImpl.java
    javac RMIServer.java
  • run it
    java RMIServer
  • if the default port 1099 is occupied, change it to an another port. In the 23rd line of RMIServer.java, then recomplie them and run.
    // open RMIRegistry
    LocateRegistry.createRegistry(1099);

client side

  • Place ComputingService.java and RMIClient.java in client
  • if your server and client isn't the same computer, change the "localhost" in 16th line of RMIClient.java to the ip address of your server
    // get register from localhost:1099(host:port)
    Registry registry = LocateRegistry.getRegistry("localhost", 1099);
  • use javac to compile them
    javac ComputingService.java
    javac RMIClient.java
  • run it and you will see an output 11
    java RMIClient

Note: if you want to run it in a project, please give the two interface file (server and client) a same package name, or you will get an error: no security manager: RMI class loader disabled


Library Management System

A traditional client/server mode library.

What does it look like?

  • Homepage homepage
  • Add a book to library addpage
  • Delete a book from library deletepage
  • Query books from library single result multiple result

How to run?

server side

  • Place LibraryServer in server side
  • Use javac to compile them
    javac service\*.java
    javac LibraryServer.java
  • Run it
    java LibraryServer
  • if the default port 1099 is occupied, change it to an another port in Line 18 of LibraryServer.java, then recompile them.
    // open RMIRegistry
    LocateRegistry.createRegistry(1099);

client side

  • Place LibraryClient in client side
  • If your server and client isn't the same computer, change the "localhost" in line 60 of view.MainController.java to the ip address of your server
    // get register from localhost:1099
    Registry registry = LocateRegistry.getRegistry("localhost", 1099);
  • Use javac to compile them
    javac -encoding utf-8 service\*.java
    javac -encoding utf-8 view\*.java
    javac -encoding utf-8 stage\*.java
  • Run it and you will see the UI window
    java stage.Main