How to tell if a java application was invoked with 'java' or 'javaw'

Discussion in 'Java' started by Michael, Nov 10, 2004.

  1. Michael

    Michael Guest

    Is it possible for a 'main' function to tell if java was invoked with
    'java' or 'javaw'?

    Thanks,
     
    Michael, Nov 10, 2004
    #1
    1. Advertising

  2. On 10 Nov 2004 06:26:05 -0800, Michael wrote:

    > Is it possible for a 'main' function to tell if java was invoked with
    > 'java' or 'javaw'?


    Sure, feed it an argument.

    But what about if it's invoked by double clicking a Jar file, or by JWS?
    What if it is instantiated by an applet?

    What is the actual problem you are trying to solve here?
    What do you hope to achieve by knowing?

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane
     
    Andrew Thompson, Nov 10, 2004
    #2
    1. Advertising

  3. "Michael" <> schreef in bericht
    news:...
    > Is it possible for a 'main' function to tell if java was invoked with
    > 'java' or 'javaw'?


    It could be that the standard streams are different.
     
    Boudewijn Dijkstra, Nov 10, 2004
    #3
  4. Michael

    Michael Guest

    The 'main' method needs to know if it can use System.out or not.
    There are at least three alternatives:

    - Have two differnet 'main' methods.
    - Use a command line argument.
    - Have the 'main' method figure it out.

    The first two options require more cooperation from the user.
     
    Michael, Nov 10, 2004
    #4
  5. On 10 Nov 2004 11:56:50 -0800, Michael wrote:

    >> What do you hope to achieve by knowing?

    ...
    > The 'main' method needs to know if it can use System.out or not.


    It can, in every circumstance.
    java, javaw, jar/no jar, JWS, applet..

    You can redirect the System.error and System.out to a file
    and throw it up in a JOptionPane if it is all so fired
    important to the user.

    But if this information is so vital to the end user, why
    are you writing it it System.out in the first place?

    [ ..and please quote a little of what you are replying to,
    to supply a context to the reader. ]

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane
     
    Andrew Thompson, Nov 10, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian Marko
    Replies:
    0
    Views:
    481
    Christian Marko
    Sep 21, 2004
  2. Robert D. Young
    Replies:
    2
    Views:
    340
    Robert D. Young
    May 2, 2005
  3. Lionel
    Replies:
    16
    Views:
    527
    Lionel van den Berg
    Dec 14, 2007
  4. The Frog

    Launching a JAVAW application

    The Frog, Oct 17, 2008, in forum: Java
    Replies:
    8
    Views:
    1,245
    The Frog
    Oct 20, 2008
  5. Luis
    Replies:
    3
    Views:
    136
    Charles Oliver Nutter
    Sep 2, 2007
Loading...

Share This Page