Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to tell if a java application was invoked with 'java' or 'javaw'

Reply
Thread Tools

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

 
 
Michael
Guest
Posts: n/a
 
      11-10-2004
Is it possible for a 'main' function to tell if java was invoked with
'java' or 'javaw'?

Thanks,
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      11-10-2004
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
 
Reply With Quote
 
 
 
 
Boudewijn Dijkstra
Guest
Posts: n/a
 
      11-10-2004
"Michael" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed) om...
> 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.


 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      11-10-2004
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.
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      11-10-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hey i am just started java,, can anyone tell me the use ,application, why java , importance of java.. manish sahu Java 3 02-14-2008 12:00 AM
How is Java typically invoked from HTML? And Java Permissions question... Aaron J. Margosis Java 7 02-12-2008 11:09 PM
Is it possible to determine if a Java application was invoked fromcommand-line? Lionel Java 16 12-14-2007 08:19 AM
How can I debug a JRuby class that is invoked from a Java application? Luis Ruby 3 09-02-2007 09:32 PM
How to tell if invoked through IDLE or command line? Robert D. Young Python 2 05-02-2005 07:09 PM



Advertisments