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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top