Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
|
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 10th, 2003, 10:30 AM
Authorized User
 
Join Date: Dec 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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);
}

}
}

 
Old December 10th, 2003, 11:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Default

According to the book you need to create the following file:

registerit.policy
-----------------

grant{
    //Allow everything for now
    permission java.security.AllPermission;
};


1. Open a new cmd window

   rmiregistry -J-Djava.security.policy=registerit.policy


2. Open a second cmd window

   java -Djava.security.policy=registerit.policy RegisterIt


3. Open a third cmd window

   java -Djava.security.policy=registerit.policy HelloClient


I've just ran this on my PC and it works OK.


Cheers

Martyn





Similar Threads
Thread Thread Starter Forum Replies Last Post
Policy File n' BCP installation reagard...! yusuf.hayath BOOK: Beginning Cryptography with Java 1 June 21st, 2008 06:30 PM
First RMI Program Pratik_Garg J2EE 1 April 4th, 2006 03:41 AM
RMI newbie NickTheBubble J2EE 0 December 17th, 2004 07:59 AM
Why rmi don't run? Edward King J2EE 2 December 7th, 2004 05:41 AM
Problem running RMI melida J2EE 0 September 23rd, 2003 09:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.