Making Java 8 DPI-aware and avoid blurry panels

Java 8 does not support DPI-aware applications unless you perform some manipulations.

NetPhantom Quick Start now makes both the preinstalled Java 8 JRE (64-bit) and JDK (32-bit) DPI-aware during installation. NetPhantom is shipping with a Windows batch file DPI-aware.bat that can add or delete the DPI-awareness of a JRE or JDK of version 8 located inherit any directory. It will work on Windows 8 through 10 and the corresponding Windows Server versions 2012 through 2019. The batch file is located in the installation root and is also shipped with the pure Editor installer as well as in the Server JAR file installation. It is furthermore included in the upgrade JAR files of the NetPhantom Server, e.g. if you upgrade NetPhantom 6.5 to 7.0. If you are interested in how the source code looks like, follow this link.

 
For the Enterprise

If you are using Windows Servers in your enterprise, you can push the DPI-aware settings onto clients at login time, e.g. using GPO or SSCM. See this post about Disabling DPI Scaling on Windows 8.1 - The Enterprise Way, still very valid for Windows 10. You can use out batch file, perhaps called from a PowerShell command or directly by manipulating the registry as the blog post above suggests.

The Java 8 programs that are affected by the DPI-awareness are java.exe, javaw.exe and javaws.exe. If jp2launcher.exe is present, then that one is affected too. This file is only present if this is a JRE as the JDK does not have this file in it's bin directory.

Note that they talk about the registry key under HKEY Current User (HKCU) that will apply the setting to the current user. If you wish to perform the same, but for all users, use the HKEY Local Machine key (HKLM) instead. Beware that you need Administrators or elevated privileges to perform registry changes using the Local Machin key (HKLM).

 
Before, when Java is DPI-unaware

Here is a screen capture of the NetPhantom Login screen with an icon when Java is running without DPI awareness on a high-resolution 4K screen with 150% default Windows scaling.

As you can see, the fonts are blurry and the icon is pixelated.

To enable Java to be DPI-aware, look-up the java.exe executable, e.g. using the Windows Task Manager:


 

Right-click on the java.exe executable and select Properties from the pop-up menu. The following dialog will be displayed:

  1. Go to the second tab Compatibility.
     
  2. Click on Change settings for all users (optionally).
     
  3. On the pop-up window, click Change high DPI settings.
     
  4. On the next pop-up window, select Override high DPI scaling behavior. Scaling performed by: Application.

 
After, when Java is DPI-aware

Here is the same screen capture of the NetPhantom Login screen with an icon when Java is running with DPI awareness, and the NetPhantom Client scales everything with 150% according to the Windows system scaling: