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