Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8601083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:45:43+00:00 2026-06-12T01:45:43+00:00

I have a GUI program that is executed by default via javaw.exe using a

  • 0

I have a GUI program that is executed by default via javaw.exe using a startup wrapper created with Launch4j.

This program can also be executed from command-line and then print output to the console.

How can I detect if a console is visible, hence that the text I output via System.out.println() is visible?

From my understanding this depends on whether the program has been started via Javaw/wrapper or directly by java -jar myprog.jar. Is there a way to distinguish both starts methods from withing the program?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:45:45+00:00Added an answer on June 12, 2026 at 1:45 am

    If System.console() returns null, there’s no console, which happens when you start the program with javaw instead of java. Example:

    import javax.swing.JOptionPane;
    
    public class Example {
        public static void main(String[] args) {
            if (System.console() != null) {
                System.out.println("Hello on the console");
            } else {
                JOptionPane.showMessageDialog(null, "Hello, there's no console");
            }
        }
    }
    

    Try compiling this and then starting it with either java Example or javaw Example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GUI program that, in this example, downloads an exe using wget
I have created a program in c++ that doesn't have any GUI. When this
I have written a java program that is actually works as a gui to
I have a GUI program, which would call a cmd in this GUI program.
I have a GUI program with one Exit button. When clicking this button, it
We have a program ( A.exe ) with GUI and a toolbar who does
I have a C# program that executes a thread. Inside this thread, I have
I have a python program that implements pygtk for GUI. I have it running
I am creating a GUI using Java. This GUI launches a program from the
I have a GUI program , that has a QLocalServer inside , each time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.