1
2
Fork 0
mirror of https://github.com/carlospolop/hacktricks.git synced 2023-12-14 19:12:55 +01:00

Update RMI source code example

This commit is contained in:
TNeitzel 2021-12-30 09:57:22 +01:00
parent 53b564d9ee
commit 03b8f4f230

View file

@ -51,17 +51,21 @@ information to connect. Thus, the situation is basically the same as with an ord
shows a small example:
```java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import lab.example.rmi.interfaces.RemoteService;
public class ExampleClient {
public static void main(String[] args) {
private static final String remoteHost = "172.17.0.2";
private static final String boundName = "remote-service";
public static void main(String[] args)
{
try {
Registry registry = LocateRegistry.getRegistry(remoteHost); // Connect to the registry
RemoteService ref = (RemoteService)registry.lookup("remote-service"); // Lookup the desired bound name
String response = ref.remoteMethod(); // Call a method on the remote object
Registry registry = LocateRegistry.getRegistry(remoteHost); // Connect to the RMI registry
RemoteService ref = (RemoteService)registry.lookup(boundName); // Lookup the desired bound name
String response = ref.remoteMethod(); // Call a remote method
} catch( Exception e) {
e.printStackTrace();