• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

rmi

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
I've been selected to go to the moon! All thanks to this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic