J
J
JVM2015-06-09 23:39:20
Java
JVM, 2015-06-09 23:39:20

How to create a remote service in JAVA using RMI?

1) I create a remote interface.
30076a8b7c3d4442ab0f17137b745aa4.png
2) I create an implementation of the remote interface 0246e6be08114c6cae3397bfd3509994.png
3) We generate "stubs" and "skeletons" using the rmic utility
and then an error ...
Warning: generation and use of skeletons and static stubs for JRMP
is deprecated. Skeletons are unnecessary, and static stubs have
been superseded by dynamically generated stubs. Users are
encouraged to migrate away from using rmic to generate skeletons and static
stubs. See the documentation for java.rmi.server.UnicastRemoteObject.
error: Class MyRemoteImpl not found.
1 error

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Eliseev, 2015-06-18
@JVM

The rmic utility is indeed outdated. You can see current examples of use, for example, in this article habrahabr.ru/post/74639 .
To use Rmi, you no longer need to generate stubs yourself using utilities, they are generated directly in the code using the UnicastRemoteObject.exportObject(service, 0);.
You may also need to set up a security policy to run RMI. To do this, create a file server.policywith the following content:

grant {
    permission java.security.AllPermission;
};

And when starting the application, specify the program argument -Djava.security.policy=server.policy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question