Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Share object in same JVM

Share object in same JVM

Scheduled Pinned Locked Moved Java
javalounge
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shivanand Gupta
    wrote on last edited by
    #1

    I am reading date time and generating random number using MyClass(Java class) that have Main function. I need to exposed one class(Exposed_class) for reading random number value from My class, to third party application (that is also written in Java). in this case there was two main that is running concurrent and want to share data.

    L J R 3 Replies Last reply
    0
    • S Shivanand Gupta

      I am reading date time and generating random number using MyClass(Java class) that have Main function. I need to exposed one class(Exposed_class) for reading random number value from My class, to third party application (that is also written in Java). in this case there was two main that is running concurrent and want to share data.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You should create a library (class or jar file) that the other application calls in order to get its information.

      S 1 Reply Last reply
      0
      • L Lost User

        You should create a library (class or jar file) that the other application calls in order to get its information.

        S Offline
        S Offline
        Shivanand Gupta
        wrote on last edited by
        #3

        yes, I agreed bu problem is that to shared variable of my current running application to other java application and if other application access my class that is OK but how to share value of my current running object.

        L 1 Reply Last reply
        0
        • S Shivanand Gupta

          yes, I agreed bu problem is that to shared variable of my current running application to other java application and if other application access my class that is OK but how to share value of my current running object.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You would need to use shared memory[^] or some sort of message passing protocol.

          1 Reply Last reply
          0
          • S Shivanand Gupta

            I am reading date time and generating random number using MyClass(Java class) that have Main function. I need to exposed one class(Exposed_class) for reading random number value from My class, to third party application (that is also written in Java). in this case there was two main that is running concurrent and want to share data.

            J Offline
            J Offline
            jschell
            wrote on last edited by
            #5

            Shivanand Gupta wrote:

            I need to exposed one class(Exposed_class) for reading random number value from My class, to third party application (that is also written in Java).

            No, you are approaching this incorrectly. What you need is a 'service' that provides a unique (presumably that is what you think you are doing) data to the caller. That service is an independent app. Then the two apps that you have use that service. That way either app can be running without the other. This of course presumes there isn't a different way to solve the problem which wouldn't require any sharing at all.

            S 1 Reply Last reply
            0
            • S Shivanand Gupta

              I am reading date time and generating random number using MyClass(Java class) that have Main function. I need to exposed one class(Exposed_class) for reading random number value from My class, to third party application (that is also written in Java). in this case there was two main that is running concurrent and want to share data.

              R Offline
              R Offline
              Raushank03
              wrote on last edited by
              #6

              For get your Solution you can visit on http://techgurulab.com/course/java-tutorials/

              1 Reply Last reply
              0
              • J jschell

                Shivanand Gupta wrote:

                I need to exposed one class(Exposed_class) for reading random number value from My class, to third party application (that is also written in Java).

                No, you are approaching this incorrectly. What you need is a 'service' that provides a unique (presumably that is what you think you are doing) data to the caller. That service is an independent app. Then the two apps that you have use that service. That way either app can be running without the other. This of course presumes there isn't a different way to solve the problem which wouldn't require any sharing at all.

                S Offline
                S Offline
                Shivanand Gupta
                wrote on last edited by
                #7

                thanks dear

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups