This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes rmi Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "rmi" Watch "rmi" New topic
Author

rmi

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

hello every body

these r prorams i have wriiten to pass arg to forvenu.exe
which residing on remote machine i want to pass arg from
client machine and get the result on client machine,i am
unable to get it.please help me regarding this
for example
at client's machine dos prompt
c>forvenu 3 4
it should all the process on remote machine and get
result back to client machine as
7
Note:the programs are written for testing on Standalone
macine so that is why in the client program,the remote
macine name is not specified.
//This is interface prog
import java.rmi.*;
import java.io.*;
public interface Hello extends Remote
{
public int add(int a,int b)throws RemoteException;
}
//This is Implementatiom prog
import java.rmi.server.*;
import java.rmi.*;
import java.io.*;
public class HelloImpl extends UnicastRemoteObject implements Hello , Serializable
{
public HelloImpl() throws RemoteException
{
super();
}
public int add(int u,int v) throws RemoteException
{
int rk=0;
String line="";
Process p=null;
try{
Runtime r=Runtime.getRuntime();
p=r.exec("forvenu.exe"+" "+"u"+" "+"v");
p.waitFor();
BufferedReader kbdin= new BufferedReader(new InputStreamReader(p.getInputStream()));
line=kbdin.readLine();
line=kbdin.readLine();
Integer ff=new Integer(line);
rk=ff.intValue();
//rk=p.exitValue();
}catch(Exception e){e.printStackTrace();}
return rk;
}
}
//This is server prog
import java.rmi.*;
import java.io.*;
public class Ser
{
public static void main(String s[]) throws Exception
{
Hello h=new HelloImpl();
Naming.rebind("ccc",h);
System.out.println("Server is ready");
}
}

//This is client prog
import java.rmi.*;
import java.rmi.server.*;
import java.io.*;
public class Clt implements Serializable
{
public static void main(String s[]) throws Exception
{
Integer p=Integer.valueOf(s[0]);
Integer q=Integer.valueOf(s[1]);
int u=p.intValue();
int v=q.intValue();
//Hello h=(Hello)Naming.lookup("rmi://180.164.51.202/ccc");
Hello h=(Hello)Naming.lookup("ccc");//first to test on stand alone system
System.out.println(h.add(u,v));
}
}
thank you
pratapani
Greenhorn

Joined: Mar 06, 2000
Posts: 3
Mr.Vishwanath
If you are using java 1 then you should the securityManager to RMISecurityManager
setSecurityManager(new RMISecurityManager());
But, if you are already using java 2.0 then, may be there is a problem in exec() method i.e while.
Durga Prasad Babu Pratapani
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: rmi
 
Similar Threads
Can we pass this object on wire?
RMI in netbeans on windows
Access Control Exception
Implementin Unreferenced
RMI return BufferedImage object from remote method