Welcome to the World of Programming

Welcome to the World of Programming

Search this blog

RMI Program to calculate Factorial of a Number

AddServerIntf.java

import java.rmi.*;

public interface AddServerIntf extends Remote{
    int fact(int d1)throws RemoteException;
}


AddServerImpl.java

import java.rmi.*;
import java.rmi.server.*;

public class AddServerImpl extends UnicastRemoteObject implements AddServerIntf{
    public AddServerImpl()throws RemoteException{}
    public int fact(int d1)throws RemoteException{
        int i,d=1;
        for(i=d1;i>1;i--){
            d=d*i;   
        }
        return d;
    }
}


AddServer.java

import java.net.*;
import java.rmi.*;

public class AddServer{
    public static void main(String args[]){
        try{
            AddServerImpl addServerImpl=new AddServerImpl();
            Naming.rebind("AddServer",addServerImpl);
        }
        catch(Exception e){
            System.out.println("Exception: "+e);
        }
    }
}


AddClient.java

import java.rmi.*;

public class AddClient{
    public static void main(String args[]){
        try{
            String addServerURL="rmi://"+args[0]+"/AddServer";
            AddServerIntf addServerIntf=(AddServerIntf)Naming.lookup(addServerURL);
            System.out.println("Number is : "+args[1]);
            int d1=Integer.valueOf(args[1]).intValue();
            System.out.println("The Factorial is : "+addServerIntf.fact(d1));
        }
        catch(Exception e){
            System.out.println("Exception : "+e);
        }
    }
}

10 comments:

  1. factorial of a number visit this http://www.123arena.com/2012/09/java-program-for-factorial-of-given.html

    ReplyDelete
  2. I appreciate your efforts because it conveys the message of what you are trying to say. It's a great skill to make even the person who doesn't know about the subject could able to understand the subject . Your blogs are understandable and also elaborately described. I hope to read more and more interesting articles from your blog. All the best.

    rpa training in bangalore
    best rpa training in bangalore
    RPA training in bangalore
    rpa course in bangalore
    rpa training in chennai
    rpa online training

    ReplyDelete
  3. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    AWS training in chennai

    AWS Training in Bangalore

    ReplyDelete
  4. Thanks for sharing The Information The Information shared is very valuable Please keep Updating us Time Just went on redaing the article Python Online Training AWS Online Training Devops Online Training Data Science Online Training

    ReplyDelete
  5. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging

    aws training in chennai | aws training in annanagar | aws training in omr | aws training in porur | aws training in tambaram | aws training in velachery

    ReplyDelete
  6. Resources like the one you mentioned here will be very useful to me ! I will post a link to this page on my blog. I am sure my visitors will find that very useful.

    Aws Training in Chennai

    Aws Training in Velachery

    Aws Training in Tambaram

    Aws Training in Porur

    Aws Training in Omr

    Aws Training in Annanagar

    ReplyDelete
  7. This post is so interactive and informative.keep update more information...
    Java Training in Tambaram
    java course in tambaram

    ReplyDelete