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 9118037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:02:48+00:00 2026-06-17T05:02:48+00:00

i am programming a virtual network. I have a central Client class which implements

  • 0

i am programming a virtual network.
I have a central Client class which implements my whole network and allows to send/receive data to/from an specific other Client in the network. I now wan’t to use a single instance of the Client class for ALL programs using the network. I have an interface for the programs to handle incoming packets, and a wrapper for sending, so I would appreciate another solution than “run a local TCP server”.

My question now is:
How can I have a single instance of a class running for all Programs using it in Java?

  • 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-06-17T05:02:50+00:00Added an answer on June 17, 2026 at 5:02 am

    This can be easily done by using RMI, RMI-IIOP or CORBA features that are available in Java. The mentioned technologies allow to create a single instance of object on a single machine (server) and export it to other computers (you say you need network) as a remote interface. In other hosts, you will have a stub class with the same interface your “real” instance implements, and will be able to call methods on it. These calls will be at the end remotely invoked on the single instance of your servant. To may opinion, this exactly that you are asking for.

    From newer, more interesting approaches, Google Protocol Buffers looks like a good thing to look at, while you need more custom code with Protocol Buffers. Web services also allow to export the interface and are more suitable to pass through firewalls (other here listed approaches are more suitable for talking between your own servers you can configure how you want).

    In case you need to ensure that only one instance of your program runs on a given operating system, this can be done as discussed in this question. If you program is listening on fixed ports, second instance probably will not start properly anyway as the ports are already taken; all you need is to catch exception when you try to bind the socked and terminate.

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

Sidebar

Related Questions

So for my programming class we have had a project to create a virtual
I have a lot of session state when programming - shell windows, ides, virtual
I am creating a program which can send test or data to Bluetooth devices.
A typical problem in OO programming is the diamond problem. I have parent class
I'm reading Programming for the Java Virtual Machine which discusses the Oolong assembler and
I've got a question concerning handling of virtual function in C++ programming. I have
I am starting on a network-programming assignment I have. The instructions are as follows:
From examples that I have seen online and in a Programming Entity Framework CodeFirst
I'm reading Programming for Java Virtual Machine by Joshua Engel book where the author
Programming language: Java Ok, so I want to have a BufferedImage that keeps rotating

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.