Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rmi BAsic Problem

 
Muhammad Ammad Husain
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.net.*;
class Implement extends UnicastRemoteObject implements Rmi {
public Implement()
throws RemoteException{
}
public void print()
throws RemoteException {
System.out.println("Printing");
}
public static void main(String args[]){
try {
System.setSecurityManager(new RMISecurityManager());
Implement a = new Implement();
Registry reg = LocateRegistry.createRegistry(2005);
reg.rebind("Implement",a);
}catch (Exception E){
System.out.println(E.getMessage());
}
////////////////////////////////////////////////
import java.rmi.*;

interface Rmi extends Remote{
void print() throws RemoteException;
}
///////////////////////////////////////
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.net.*;
class Test {
public static void main(String args[]){
try {
System.setSecurityManager(new RMISecurityManager());
Registry reg = LocateRegistry.getRegistry("personal",2005);
Rmi r = (Implement)reg.lookup("Implement");//Naming.lookup("//personal:2005/Implement");
r.print();
}catch (Exception E){
System.out.println(E.getMessage());
}
}
}
///////////////////////////////////////////////
These are three simple files every thing seems to Ok But when i run Client Message appears stating that,
acess denied, (java.net.socketPermission,Personal resolve)
I have tried every thing but didnt got any resuce.
Plz Send me atleat simplfied code to over come this problem

}

}
 
Jawad Kakar
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope this example will help

The Remote interface

Client

Hope this example will help
Jawad
 
Javan Li
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess u need a policy file. like this:

grant {
permission java.net.SocketPermission "*:1024-65535", "accept, connect,listen";
permission java.io.FilePermission "<<ALL FILES>>", "read, write, delete, execute";
};
 
Muhammad Ammad Husain
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes persmission really Solve my problem , thanks Alot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic