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:
parent
53b564d9ee
commit
03b8f4f230
|
@ -51,17 +51,21 @@ information to connect. Thus, the situation is basically the same as with an ord
|
||||||
shows a small example:
|
shows a small example:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
import java.rmi.registry.LocateRegistry;
|
|
||||||
import java.rmi.registry.Registry;
|
import java.rmi.registry.Registry;
|
||||||
|
import java.rmi.registry.LocateRegistry;
|
||||||
|
import lab.example.rmi.interfaces.RemoteService;
|
||||||
|
|
||||||
public class ExampleClient {
|
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 {
|
try {
|
||||||
Registry registry = LocateRegistry.getRegistry(remoteHost); // Connect to the registry
|
Registry registry = LocateRegistry.getRegistry(remoteHost); // Connect to the RMI registry
|
||||||
RemoteService ref = (RemoteService)registry.lookup("remote-service"); // Lookup the desired bound name
|
RemoteService ref = (RemoteService)registry.lookup(boundName); // Lookup the desired bound name
|
||||||
String response = ref.remoteMethod(); // Call a method on the remote object
|
String response = ref.remoteMethod(); // Call a remote method
|
||||||
|
|
||||||
} catch( Exception e) {
|
} catch( Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in a new issue