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 ExchangeTo 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
- Click Start
- Select Settings
- Select Control Panel.
- Double click the Java icon.
- Click the Advance tab.
- Click on the + sign
- Select Show Console and click Apply.

Videos
If you've manually installed Oracle Java it doesn't show up in the Dash (as far as I know).
- Open a terminal
Execute the following command:
/usr/bin/jdk1.8.0_05/bin/ControlPanelReplace
/usr/bin/jdk1.8.0_05by the path of your Java installation.
Open a terminal (Ctrl-Alt-T) and start
ControlPanel
Just a few moments later the Java Control Panel appeared. I haven't checked yet, but it may be necessary to
sudo ControlPanel
to save your changes.
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).
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.