Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top