This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of TensorFlow 2.0 in Action and have Thushan Ganegedara on-line!
See this thread for details.
Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Problems with Java RMI

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I am new to Java RMI and I am simply trying to run a "Hello World" program which was slightly modified. (code is shown at the end of the message)

Basically, I have a remote class, a remote interface, and a server class in one of my computers and a client class in another computer.
I am trying to get a "hello" message from the server using the client.
I compiled the server/remote class/interface using javac and then using the rmic compiler. I can run the server and the stub with no problem.
When I try to run the client, I received errors:

cannot find symbol
symbol : class HelloInterface
location: class Client
HelloInterface hello = (HelloInterface)Naming.lookup(host);

I am wondering what would the problem be and how could I get this to work.
In addition, I believe I am using a stream TCP connection. How could I use a datagram UDP instead?

Thanks in advance!

Remote Interface:

Remote class:


Posts: 1210
Android Python PHP C++ Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which JavaSE version are you on? From the code and description (rmic, use of java.rmi.Naming), it looks like you're using a J2SE 1.3 example. But RMI concepts have changed a bit (evolved?) since then. I'll explain both how to get your existing version to work, as well as how to migrate to the newer concepts.

Getting your existing system to work: Checklist
  • Have you packaged your remote interface into a separate jar? This jar - the interface jar - containing remote interface definition and any types it uses, should be in the classpaths for rmiregistry, server and client.
  • Are the stub classes available in classpath for rmiregistry?
  • Are you running rmiregistry? (since you say server and stub are running ok, you must be running rmiregistry correctly, but just checking...)
  • Are you starting the components in this order: First: rmiregistry Second:server Last: client?

  • Migrating to JavaSE1.5 RMI concepts:
    The lookup and stub concept are changed as follows :
  • The java.rmi.Naming was a custom naming scheme specifically for RMI. Now, >JavaSE 5, it's preferred to use the standard JNDI concept like this:

  • server:


  • Prior to JavaSE 5, RMI involved stub classes generated using rmic on the server class. Since JavaSE 5, these are not needed because stubs are generated dynamically (using the dynamic proxy concept java.lang.reflect.Proxy) at runtime. So you can skip the rmic step completely.

  • Regarding UDP:
    When I saw UDP, I went ! RMI does allow the use of custom socket factory, but the custom sockets have to be TCP sockets (ie, subtypes of, like SSLSocket). If you want to use UDP for RPC, you can - but not using any of the RMI infrastructure or APIs. Or you'd have to perform some contortions like using a TCP over UDP implementation. Why do you wish to use UDP for RPC?
    Micheal Kim
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you for your reply, Karthik Shiraly

    You were right, I actually just had to skip the rmic step and everything worked wonderfully!

    Regarding the UDP, I was a little bit confused about how RMI is implemented and I was wondering if there was an easy and simple way of changing from TCP to UDP.
    I see now that it is not how things work, but thanks for clarifying this to me!

    I really appreciate your help.
    Thanks again,
    You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
    Thread Boost feature
      Bookmark Topic Watch Topic
    • New Topic