Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7128413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:08:10+00:00 2026-05-28T11:08:10+00:00

I have two packages client and server: the client package contains an interface I_object:

  • 0

I have two packages client and server:

enter image description here

the client package contains an interface “I_object”:

package client;

import java.rmi.Remote;

import java.rmi.RemoteException;

public interface I_object extends Remote {  

public int Add(int a,int b) throws RemoteException;

}

and a class main_client:

package client;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

/**
*
* @author marwen
*/

public class main_client {


public static void main(String [] args) throws NotBoundException,  MalformedURLException, RemoteException{

 I_object obj_distant=(I_object) Naming.lookup("rmi://localhost:1000/exemple");

 System.out.println(obj_distant.Add(5, 9));    

}
}

The server package contains a class(impl_object ) that implements the interface I_object:

package server;

import java.rmi.RemoteException;

import java.rmi.server.UnicastRemoteObject;


/**
*
* @author marwen
*/
public class impl_object  extends UnicastRemoteObject implements I_object {

public impl_object() throws RemoteException
{}

public int Add(int a,int b) throws RemoteException{
return a+b;
}

}

and finally a main_server:

package server;

import java.net.MalformedURLException;

import java.rmi.Naming;

import java.rmi.NotBoundException;

import java.rmi.RemoteException;


public class main_server {

public static void main(String [] args) throws NotBoundException, MalformedURLException, RemoteException{

    impl_object obj=new impl_object();

   java.rmi.registry.LocateRegistry.createRegistry(1000);

   Naming.rebind("rmi://localhost:1000/exemple", obj);

 System.out.println("server is running");
}
}

if you noticed in the implementation of “impl_object” , i have not put an “import client.I_object;” why???????
okay , precisely, if I put an “import client.I_object;” to the client package, So the server will be “linked” to the client !!! that’s the problem , When I separate the client and the server (I put the server on a remote computer and the client at home)???….
Can someone explain to me, I’m wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T11:08:10+00:00Added an answer on May 28, 2026 at 11:08 am

    EDITED ANSWER:

    You can your interface and impl class into a separate package like model and then import them from this package if you like. Impl object is the object used by both server and client it doesn’t bind them in this way (client only way). It’s UnicastRemoteObject to be used with JRMP and they both have to be aware of this object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java project that has both server and client packages. In addition
I have an SSIS Package with two steps: 1) FTP in to a server
I have a server application and two Swing-based client applications. We're developing them in
I have two packages - x and y. x contains the Student class and
I am evaluating datamining packages. I have find these two so far: RapidMiner Weka
I have these two modules : package G1; sub new { my $class =
I'd like to be able to have two protected classes in my package. That
Have two folders with approx. 150 java property files. In a shell script, how
I have two applications written in Java that communicate with each other using XML
I'm trying to pick up Java and wanted to test around with Java's client/server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.