How do I run Java apps upscaled on a high-DPI display?

The problem here seems to be that Swing is by default claiming that it is DPI aware, so windows doesn't scale it. Use this switch to turn off this behavior and windows will start scaling your swing app:

-Dsun.java2d.dpiaware=false

[EDIT: Unfortunately, this flag no longer seems to work in Java 8, I was testing it in Java 6. Looks like this is a known issue.]

[EDIT 2: You can modify a Java 8 install to work correctly, using a program to modify the EXE manifests. I changed the setting from true to false in the manifests inside of java.exe and javaw.exe, and now my Swing programs scale correctly in Windows 10 high dpi. I used Resource Tuner to this.]

[Edit 3] Just use Java 9


Just found an easy solution on my Windows 10 machine:

  1. Find java.exe you installed.
  2. Right click -> Properties
  3. Go to Compatibility tab
  4. Check Override high DPI scaling behavior.
  5. Choose System for Scaling performed by:

If you stumbled across this question but are actually looking for a solution that works on Linux, this is for you.

If you can add parameters to the java binary which launches the application, you can use the option -D to pass a value for the sun.java2d.uiScale proprty to specify a scaling factor for Java2D. This will scale your application. The scaling factor value is a double. Make sure that you pass this option to the java binary itself, not the launched Java application.

Example: Launch NearInfinity.jar with a UI scaling factor of 2.5

java -Dsun.java2d.uiScale=2.5 -jar ~/jars/NearInfinity.jar

Alternatively, you can set the GDK_SCALE environment variable. Example:

GDK_SCALE=2 java -jar ~/jars/NearInfinity.jar

I found this ArchLinux Wiki article quite useful in general for running Linux on HiDPI systems, and some of the things might work on Windows as well.