how will create policy file in rmi
sir
i have new in rmi.
i have do'nt know the way of creating policy file
please send the way in detail
i have work in j2sdk1.4.0.
i have attach the code.please send the method for
running rmi and create policy file in detail.
yours siva
interface.java
-------------
public interface hellointerface extends java.rmi.Remote
{
public String sayhello() throws java.rmi.RemoteException;
}
helloserver.java
----------------
import java.rmi.*;
import java.io.*;
import java.rmi.server.*;
import java.util.Date;
public class helloserver extends UnicastRemoteObject implements hellointerface
{
public helloserver() throws RemoteException
{
super();
}
registerit.java
------------------------
import java.rmi.*;
public class registerit
{
public static void main(String ar[])
{
try{
helloserver obj=new helloserver();
System.out.println("object instantiated"+obj);
Naming.rebind("/helloserver",obj);
System.out.println("hello server bound in registry");
}
catch(Exception e)
{
System.out.println(e);
}
}
}
public String sayhello() throws RemoteException
{
return "hello word, the current system time is " + new Date();
}
}
helloclient.java
----------------------
import java.rmi.*;
public class helloclient
{
public static void main(String ar[])
{
if(System.getSecurityManager()==null)
System.setSecurityManager(new RMISecurityManager());
try{
hellointerface obj=(hellointerface) Naming.lookup("/helloserver");
String message=obj.sayhello();
System.out.println(message);
}
catch(Exception e)
{
System.out.println("helloclient exce"+e);
}
}
}
|