To view the Java console, right click on the Java icon in the system tray (assuming you're using Windows) and choose "Open console" - as pictured at the bottom of this page

Answer from George3 on Stack Exchange
🌐
Oracle
java.com › en › download › help › javaconsole.html
How do I enable and view the Java Console?
Select Show Console and click OK. NOTE: These instructions apply if you've chosen to place the Java icon in the system tray through the Java Control Panel (Advanced tab) ... Select Open Console.
🌐
State
scc.its.state.nc.us › hod › en › doc › troubleshoot › javaconsole.html
Displaying the Java Console
The Java Console window appears. To display the Java Console when running the Java 2 plug-in, double click the Java icon in the bottom-right side of your screen.
Top answer
1 of 14
21

I found this while looking for an answer myself, I ended up writing this bit:

/**
 * This opens a command line and runs some other class in the jar
 * @author Brandon Barajas
 */
import java.io.*;
import java.awt.GraphicsEnvironment;
import java.net.URISyntaxException;
public class Main{
    public static void main (String [] args) throws IOException, InterruptedException, URISyntaxException{
        Console console = System.console();
        if(console == null && !GraphicsEnvironment.isHeadless()){
            String filename = Main.class.getProtectionDomain().getCodeSource().getLocation().toString().substring(6);
            Runtime.getRuntime().exec(new String[]{"cmd","/c","start","cmd","/k","java -jar \"" + filename + "\""});
        }else{
            THEMAINCLASSNAMEGOESHERE.main(new String[0]);
            System.out.println("Program has ended, please type 'exit' to close the console");
        }
    }
}

not sure if my answer is still relevant, but feel free to use it with the comment kept in o/

Only flaw I can think of is that it leaves the cmd window open after the program completes.

Usage: place this class in the same package as your main class and set it as the main class, it will open a command prompt window if one is not open, or if one is open launch the main class. Name / location of jar file is automatic. Designed for windows, but if you want it for another system just message me and I'll fix it. (I could do OS detection but I'm lazy and just making this so I can turn in a double-click jar file to my professor who uses windows).

2 of 14
5

If you want full control, you can implement a Console window in Swing which does what you have now.

If you cannot open said window (if headless) or the user asks for it on the command line, then just default to your current behaviour.

🌐
University of Illinois
ks.uiuc.edu › Research › biocore › fom.cgi
BioCoRE Collaboratory FAQ: How do I display the Java Console for the Control Panel Web Start application?
From time to time, it might be useful to view the Java standard out text console. The BioCoRE Control Panel can send debugging information there as can other Web Start programs that you might want to run. In its default configuration, you won't ever see the Java console.
Find elsewhere
🌐
Apple Community
discussions.apple.com › thread › 8049198
How to Open a Java Console window? (OS 10… - Apple Community
August 30, 2017 - I'm using some open source software on my desktop that can only be invoked from a Java console window. I went to: System Preferences>Java>Advanced and selected "Show console" ...but now what?
🌐
Bentley Communities
bentleysystems.service-now.com › community
AssetWise Linear Network Management - How to Enable the Java Console - Communities
AssetWise Linear Network Management - How to Enable the Java Console - Product(s): Exor Network Manager Version(s): NA Environment: NA Area: N/A Subarea: NA Sometimes Support
🌐
Oracle
docs.oracle.com › cd › E19120-01 › open.solaris › 819-2379 › swc123 › index.html
Getting Started With the Java Web Console (System Administration Guide: Basic Administration)
If RBAC is enabled on the system, and your user identity is assigned to a role, you are prompted for a role password after you have successfully logged in. If you assume a role, authorization checks are made for the assumed role. You can opt out of assuming a role by selecting NO ROLE, and then authorization checks are made against your user identity. Following a successful authorization check, the web console launch page is displayed. Start a web browser that is compatible with the Java Web Console, such as Firefox 1.0.
🌐
PTC
support.ptc.com › help › arbortext › r8.1.2.0 › en › Program › programmer_ref › help5102.html
Accessing the Java Console
There are two ways in which you can access the Java Console: • Choose Tools > Administrative Tools > Java Console.
🌐
Customer Support
support.quotemedia.com › support › solutions › articles › 13000005197-enabling-and-capturing-java-logs-windows-
Enabling and Capturing Java Logs (Windows) : Customer Support
February 7, 2017 - 2. In the Java Control panel, select the 'Advanced' tab and ensure that under Debugging 'Enable tracing,' and 'Enable logging,' are selected, as well as 'Show console' under Java Console.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › guides › deploy › console_trace_log.html
Java Console, Tracing, and Logging
April 21, 2026 - This topic describes the Java Console, a debugging aid that redirects any System.out and System.err to the console window. The console is available for applets running with Java Plug-in and applications running with Java Web Start.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-open-command-prompt-insert-commands
Java Program to Open the Command Prompt and Insert Commands - GeeksforGeeks
April 22, 2025 - It is done by passing "cmd" command to exec() method. ... // Java program to illustrate // open cmd prompt class Geeks { public static void main(String[] args) { try { // Just one line and you are done !
🌐
Javatpoint
javatpoint.com › java-console-class
Java Console Class - javatpoint
There is a cursor implied to the array called file pointer, by moving the cursor we do the read write operations.... ... Java is a class which is used to convert character stream to byte stream, the characters are encoded into byte using a specified charset. write() method calls the encoding converter which converts the character into bytes.
🌐
Oracle
docs.oracle.com › javase › tutorial › essential › io › cl.html
I/O from the Command Line (The Java™ Tutorials > Essential Java Classes > Basic I/O)
A program is often run from the command line and interacts with the user in the command line environment. The Java platform supports this kind of interaction in two ways: through the Standard Streams and through the Console. Standard Streams are a feature of many operating systems. By default, they read input from the keyboard and write output to the display.
🌐
Princeton CS
introcs.cs.princeton.edu › java › 15inout › windows-cmd.html
Java and the Windows Command Prompt
April 10, 2020 - Prepend C:\Program Files\Java\jdk1.6.0_27\bin; to the beginning of the PATH variable. Click OK three times. You will type commands in an application called the Command Prompt. Launch the command prompt via All Programs -> Accessories -> Command Prompt. (If you already had a command prompt window ...
🌐
NewbeDEV
newbedev.com › how-do-i-make-my-java-application-open-a-console-terminal-window
How do I make my java application open a console/terminal window?
/** * This opens a command line and runs some other class in the jar * @author Brandon Barajas */ import java.io.*; import java.awt.GraphicsEnvironment; import java.net.URISyntaxException; public class Main{ public static void main (String [] args) throws IOException, InterruptedException, URISyntaxException{ Console console = System.console(); if(console == null && !GraphicsEnvironment.isHeadless()){ String filename = Main.class.getProtectionDomain().getCodeSource().getLocation().toString().substring(6); Runtime.getRuntime().exec(new String[]{"cmd","/c","start","cmd","/k","java -jar \"" + fil