• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javaw and javaw Detection from within Program

 
Tom Angioletti
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can a running java program detect whether java.exe or javaw.exe was used to launch it?
 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure that you can. Why do you need to know this? Maybe we can offer an alternate way of doing whatever it is you are trying to do.
Brian
 
Tom Angioletti
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind, I found a way to do it:

import javax.swing.*;
public class TestJavaw
{
public static void main(String[] args)throws Exception
{
System.out.println("Test");
System.out.flush();
JOptionPane.showMessageDialog(null, "check="+System.out.checkError(), "check", JOptionPane.ERROR_MESSAGE);
}
}
checkError returns true if run under javaw and false if run under java.
I found the suggestion via Google here
http://www.geocrawler.com/archives/3/196/1998/5/0/1082544/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic