Java - Mac / Windows with System.out.println ()

We mainly use System.out.println in the console of our development environment. I am using Eclipse. I can also see the println () message in the Mac Console app. Which is nice for my personal belongings.

And here's the code:

public class Main {

    public static void main(String[] args) {

        System.out.println("Is this logged anywhere?");

    }

}

      

And this is what I see on my Mac:

enter image description here

Does Windows have something similar to the Mac console version?

+3


source to share


2 answers


Unfortunately, as stated earlier, we don't actually have this on Windows. Your best options are to run your program from CMD and then plug the standard into the file. Something like java -jar HelloWorld.jar> hello.txt.

What I usually do is create a handler for the log file (usually this is just the name [program_name] log [date] .txt and all the messages printed there, depending on the log level, which is good practice if you are used to using only System out printouts.



The simple answer is that none of this functionality comes standard with Windows. You will have to connect to the file somehow.

+2


source


This is not true. However, you can just start the process from the command line if you want to examine its stdout. (As you said, eclipse works too, of course.)



+2


source







All Articles