Something hard, something simple. Jar Calling Jar

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jimhawkss
    New Member
    • Feb 2008
    • 10

    Something hard, something simple. Jar Calling Jar

    I have searched for about 4 days to try to find this, and have decided I'm horrible with searching.

    I am trying to execute a Jar with a button from another Jar'd Application.

    Basically I have a program. Works nice and fine and I don't want to mess with it other then adding a button.

    I want this button to call another program which also works nice and fine.

    I don't want to put them together completely because one keeps track of an ungodly amount of arrays and linked lists. (which is the one I want to be able to call with the button)

    SO any help would be helpful.

    Thanks in advance. JimHawkss
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    Did you write both of these programs? I'm asking because that gives more options to you.

    Lets call the programs the Caller and the Callee. What is the nature of the communication between the two? Does the Caller pass data to the Callee? Does the Callee return an answer? Is there further interaction?

    Comment

    • jimhawkss
      New Member
      • Feb 2008
      • 10

      #3
      Oh sorry about that.
      Yes I made them both, at this time they don't communicate with one another.
      Basically they both mess with a text file. One makes them, about 14 of them.
      It allows the user to create up to 14 different linked lists, each node of which containing a Name String, Int array of a 3 size, and a String array of an (technically) undeclared size.
      Since it auto loads the files, for easy user input / manip, I will end up having alot of arrays, nodes, and ect in memory at one time. SO I don't want to make it a part of the other program. I would rather have the other program call it (via button) so I can close it and free up memory when not in use.

      The other program (the caller prog). It will only use One of the files at a time, but I only want it to be able to read said files. That way I have less chance of an idiot (me) accidentally erasing a bunch of hard work when reading the stuff I put in there. I already have it able to read one file at a time, and clear the linked list that the one file makes when I'm done (aka freeing the memory back up). I just want to be able to load up the other program when needed as an "Add on" program in case I need to change something spur of the moment.

      Sorry about not being clearer earlier. I'm sure it would have helped.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        I can think of two ways. Do whatever is done in your second program's main method in the actionPeformed for that button
        or start the second program using the Runtime class by running the java command on the main class.

        Comment

        • BigDaddyLH
          Recognized Expert Top Contributor
          • Dec 2007
          • 1216

          #5
          Originally posted by jimhawkss
          I don't want to make it a part of the other program. I would rather have the other program call it (via button) so I can close it and free up memory when not in use.
          Is this code for a tiny device like a Java-enabled toothpick? ;-)

          If not, I think you are too worried about freeing memory. Let Java and its garbage collection take care of that. I would merge these two programs into one. As long as your design is clean, this is the simplest way to go. Why create artificial barriers for yourself?

          Comment

          • jimhawkss
            New Member
            • Feb 2008
            • 10

            #6
            This thread is officialy solved. Got it running with the Runtime.exec(ja va -jar)
            Thanks for pointing me in the accurate direction r035198x.
            And BDLH I appreciate the help and for reminding me to clerify.

            Comment

            Working...