Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By Junky

Thread: initiating an independent java project

  1. #1
    snaketron is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default initiating an independent java project

    Hello I have the following question:

    Lets say we have two java projects A and B. B is in the path of A and is initiated by it. How can I make sure that B is an independent project so that if A is terminated, it could continue operating? Or vice versa, B is terminated and A continues to work.

    In the practical example below whenever the JFrame is closed the class A is also closed. How can I avoid this?


    Java Code:
    public class A{
    
    	public static void main(String[] args) {
                     B.main(null);
            }
    }
    
    public class B{
    
    	public static void main(String[] args) {
    		JFrame frame = new JFrame("My frame");
    		frame.setLayout(null);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setSize(300, 250);
    		frame.setVisible(true);	
    	}	
    }
    Best regards!

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: initiating an independent java project

    I have no idea what you are trying to achieve but class A "closes" because it has nothing more to do.
    tnrh1 likes this.

  3. #3
    snaketron is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Re: initiating an independent java project

    Even if I add a while(true) loop in class A after initiation of the B class, whenever I close the JFrame in class B, the class A will also be closed.

    All I want is class A to be independent of class B so when the JFrame is closed the class A would continue working.


    OR

    the other way around. I do not want closing the class A to close class B. In other words what I want to achieve is having two totally separate and independent processes which can communicate :)

    PS.I have no idea if this is possible just asking....
    Last edited by snaketron; 12-14-2011 at 11:45 PM.

  4. #4
    snaketron is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Re: initiating an independent java project

    Solved it! Thanks for replying though!

  5. #5
    kevinn205 is offline Member
    Join Date
    Nov 2011
    Posts
    65
    Rep Power
    0

    Default Re: initiating an independent java project

    Well one option is to run it as a seperate JVM

    bascily you just dont launch it off of A , you launch it off of its own main


    if it has to do with frames try disposing one frame instead of a system.exit


    best of luck
    Last edited by kevinn205; 12-14-2011 at 11:55 PM.

Similar Threads

  1. Why is this for loop not initiating?
    By Scopic in forum New To Java
    Replies: 4
    Last Post: 10-22-2011, 10:20 PM
  2. Java, USB, System Independent
    By yellowledbet in forum New To Java
    Replies: 0
    Last Post: 07-06-2011, 05:30 AM
  3. Initiating a JFrame form
    By ZaabZ in forum New To Java
    Replies: 5
    Last Post: 08-28-2010, 08:15 PM
  4. initiating objects question(kinda)
    By helpisontheway in forum New To Java
    Replies: 4
    Last Post: 01-11-2010, 03:07 AM
  5. Why and how Java is a Platform Independent?
    By gopivista in forum New To Java
    Replies: 7
    Last Post: 09-01-2009, 04:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •