?
Solved

Java RMI simple client-server application

Posted on 2004-12-01
7
Medium Priority
?
1,284 Views
Last Modified: 2012-05-05
I need to know how to write a simple java RMI server - client application to play a lottery. The player shuld select 6 distinct numbers in the range 1-100 and wins if any one of those numbers matches the single number generated at random on the server.
The lotto server receives and reads the list of numbers selected by the client, then it checks that the list is valid, if not, it return an error message and if yes, the lottery draw and see if the client has any winning numbers. The server then returns the result to the client.
0
Comment
Question by:chris_black23
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12715995
We can't produce homework code. Break the problem down. Look for the Sun tutorials
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 256 total points
ID: 12716019
One thing you can do is to produce the random classes independently of the RMI stuff to begin with
0
 
LVL 2

Assisted Solution

by:mtcmedia
mtcmedia earned 248 total points
ID: 12716399
I would do as CEHJ says, you can go and create your "template" RMI classes which are standard no matter what your going to do. Look at Suns pages, once you have that then you can start adding the functionality you need.
0
 
LVL 17

Assisted Solution

by:Dejan Pažin
Dejan Pažin earned 248 total points
ID: 12717341

And dont forget: Using java 1.5, all the RMI stuff can be generated for you. Try it with IntelliJ IDEA, you can get a trial licence. All you need to do is, check: Compiler --> RMI Compiler --> Enable RMI stubs generation.

The only thing you need to do is create an interface, which extends Remote, and implement it. And of course start the rmiregistry, register the object and then call the methods on it from the client. This is how you do it for the server side:

         Registry registry = LocateRegistry.createRegistry(portNo);
         registry.bind("NameForYourServerObject", yourServerObject);

And then call it on the client:

         Registry registry = LocateRegistry.getRegistry("localhost", portNo);
         serverObject = (ServerObjectClass) registry.lookup("NameForYourServerObject");

It really is that easy.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 248 total points
ID: 12721776
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question