NOTE: This article is 3 years or older so its information may no longer be relevant. Read on at your own discretion! Comments for this article have automatically been locked, refer to the FAQ
for more details.
I've been playing around a little with JNativeHook
Java library. "JNativeHook is a library to provide global keyboard and mouse listeners for Java. This will allow you to listen for global shortcuts or mouse motion that would otherwise be impossible using pure Java."
What I really didn't like is it printed its licence details every time my code ran. I've dug into the JNI code and saw that it makes a callout to System.out
to print this information. My solution was pretty simple, just disable the system output stream during initialisation.
This is the text that I was seeing every time my code ran...
Ok yeah I get it, but it doesn't have to be printed every single time. It's enough to include the licence text file.
So this is how I initialise...
Now when my code starts I don't get any notices and no logging info printed from JNativeHook.
A quick disclaimer...
Although I put in a great effort into researching all the topics I cover, mistakes can happen.
If you spot something out of place, please do let me know.
All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle).
Use of any information contained in this blog post/article is subject to this disclaimer
Other posts you may like...