1

When writing code, for debugging purposes, you typically add System.out.println("something to print"), which prints to the output window of the IDE.

When you compile your code to a JAR or an EXE, hence running the application outside the IDE, does the application still print? or do print statements get ignored?

melkhaldi
  • 899
  • 2
  • 19
  • 40

1 Answers1

1

It depends on how you're running your application and possibly the system you're running on.

If you're running a JAR using java -jar Foo.jar on the command line then System.out will direct content to the console in which the program was run.

Java applications that don't use a console are typically run with javaw instead of java. The javaw program runs without a console and, according to this answer, the output stream will be null. This behavior may depend on the JDK and/or the OS.

Community
  • 1
  • 1
Eric
  • 6,965
  • 26
  • 32