This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needed in RMI

 
Jane Cecilia
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my Interface program
-------------------------------

import java.rmi.*;

public interface Sum extends Remote
{
public String getResult(int n,int n1) throws RemoteException;
}


This is my Client program
----------------------
import java.rmi.*;
import java.io.*;

public class SumClient
{
public static void main(String args[])throws IOException
{
String result;
int n,n1;

try
{
Sum s = (Sum)Naming.lookup("SumServer");
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter two Integers");
n = Integer.parseInt(br.readLine());
n1=Integer.parseInt(br.readLine());
result=s.getResult(n,n1);
System.out.println("The sum of two Integers is "+ result);
}
catch(Exception e)
{System.out.println(e);}
}
}

----------------
This is my Server program
--------------------------
import java.rmi.*;
import java.rmi.server.*;
import java.io.*;
import java.net.*;
import java.util.*;

public class SumServer extends UnicastRemoteObject implements Sum
{
public SumServer() throws RemoteException
{}

public String getResult(int n,int n1) throws RemoteException
{
int result=0;
result= n + n1;
return(Integer.toString(result));
}
public static void main(String args[]) throws Exception
{
SumServer s = new SumServer();
Naming.rebind("SumServer",s);
System.out.println("Server is ready, please input at the client side to process at the

server side");
}
}

The issue I am facing is...I am able to compile the Interface program, but not able to compile both the client and the server program

the error is

cannot resolve the symbol Sum class Sum in SumServer etc...

all the programs are in the same directory..what would be wrong. Please someone out there help me!!!

Thankz

Cecilia
 
Inuka Vincit
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it compiles for me...
hmm why would it
you have set your classpath incorrecttly, make sure you have a . in there.
like so
CLASSPATH = c:\scjd\src;C:\junit\junit.jar;C:\junit;.

see the dot at the ends, basically tells the OS to include the current path.
 
Jane Cecilia
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still doesnt work tried to set the class path, still no luck
what next?

actually the other java programs work just fine...

I wonder what might be wrong!!!

Please Help!!!

Thankz

Cecilia
 
Jane Cecilia
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi am back...

Thank you Inuka, I again checked and verified and then corrected my ClassPath, now it works perfectly...Thankz a lot

)))))))))))

Cecilia
 
Jane Cecilia
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!!!

After I set the classpath, servlet programs do not compile says cannot resolve symbol: class GenericServlet..etc

Please help!!!

awaiting

Cecilia
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jane Cecilia:
Hi!!!

After I set the classpath, servlet programs do not compile says cannot resolve symbol: class GenericServlet..etc

Please help!!!

awaiting

Cecilia


You really shouldn't change the system environment CLASSPATH variable. Its much better to specify this in you command using the -cp argument. The best way of course since you are working toward the SCJD is to use ANT to build your system and build a .jar file. Then you simply run the jar file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic