Results 1 to 10 of 10
  1. #1
    AhmedAdel is offline Member
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default How to run tow main class exsit in one project

    i have tow main class
    1-org.SplashScreen.SplashScreen
    2-t24_transformer_form.T24_Transformer_FormApp

    how can handel my project so will run fisrt main class
    and after finish run the second main class

    Plesae help me

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Have the second call the main method of the first.

  3. #3
    AhmedAdel is offline Member
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default please need more clarification

    Quote Originally Posted by masijade View Post
    Have the second call the main method of the first.
    Please added more clarification

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Java Code:
    public class Splash {
      public static void main(String[] args) {
        // do something
      }
    }
    
    public class App {
      public static void main(String[] args) {
        Splash.main(args);
        // do rest
      }
    }

  5. #5
    AhmedAdel is offline Member
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default

    thanks for your important
    i deployed your code but only first package splash only run and second package not run

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,432
    Rep Power
    18

    Default

    I suspect you wrote it incorrectly then.
    masijade's code will run both.

    How about posting some code. It should be a simple case for you to show us the code that fails to run both main().

  7. #7
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    Java Code:
    public class Splash {
      public static void main(String[] args) {
        // do something
      }
    }
    
    public class App {
      public static void main(String[] args) {
        Splash.main(args);
        // do rest
      }
    }
    first package splash only run and second package not run
    If you code it like this, than you must select your main class to be App, and not class Splash.
    I guess that you've selected first class to be your main class

  8. #8
    vishu.ankur is offline Member
    Join Date
    Apr 2010
    Posts
    1
    Rep Power
    0

    Default

    if wanna run your code then you must put your code in two different packages correspondingly.or if you still wanna two main functions inside one file then you must define the one main as PSV main(String args[]) and another as psv main(any valid data type but 'String args[]') and name that file as the name of the class holding the main(String args[]).other wise it will not run.

  9. #9
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    ??????????????

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,432
    Rep Power
    18

Similar Threads

  1. Replies: 6
    Last Post: 05-18-2010, 05:11 PM
  2. How can I change the main class of a project?
    By batya in forum AWT / Swing
    Replies: 2
    Last Post: 11-17-2009, 07:55 PM
  3. Replies: 1
    Last Post: 06-30-2009, 02:32 PM
  4. different multiple public class and main class
    By mr idiot in forum New To Java
    Replies: 2
    Last Post: 01-01-2009, 12:10 PM
  5. How to create main class link to another two class?
    By pearllymary78 in forum New To Java
    Replies: 6
    Last Post: 07-16-2008, 11:02 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
  •