Search code examples
javajinput

Suppress JInput Warnings


My JInput code works fine, it just prints these warnings to the console every time the program starts. I need to suppress them.

Nov 29, 2017 8:59:55 AM net.java.games.input.DefaultControllerEnvironment getControllers WARNING: Found unknown Windows version: Windows 10 Nov 29, 2017 8:59:55 AM net.java.games.input.DefaultControllerEnvironment getControllers WARNING: Attempting to use default windows plug-in.

EDIT: I found a way to do it, but it's a bit of a hack: System.err.close(); Is there a way for me to temporarily disable System.err ?


Solution

  • The solution is to use System.setErr():

        PrintStream error=System.err;
        System.setErr(new PrintStream(new OutputStream(){
            public void write(int a){}
        }));
        controllers=ControllerEnvironment.getDefaultEnvironment().getControllers();
        System.setErr(error);