Is there a way to know if a Java program was started from the command line or from a jar file?

Posted by Oscar Reyes on Stack Overflow See other posts from Stack Overflow or by Oscar Reyes
Published on 2010-05-20T00:13:21Z Indexed on 2010/05/20 0:20 UTC
Read the original article Hit count: 489

I want to either display a message in the console or a pop up, so in case a parameter is not specified, I want to know to which should I display

Something like:

if( !file.exists() ) {
    if( fromCommandLine()){
        System.out.println("File doesn't exists");
    }else if ( fromDoubleClickOnJar() ) {
        JOptionPane.showMessage(null, "File doesn't exists");
    }
 }

© Stack Overflow or respective owner

Related posts about java

Related posts about commandlline