How to scale Java applications for HiDPI / 4k displays / etc.

Cluster (acc9)

Many apps just listen to the window scaling that can be configured via Applications => Setting => Appearance => Settings => Window Scaling. For Java applications, this apparently isn't sufficient. Here are some tips to make those applications change their scaling.

Recommended: Environment variable GDK_SCALE

This is the easiest and most general way!

Open a console/terminal:

export GDK_SCALE=2

Any Java applications started from that terminal (e.g. sqldeveloper, via webstart ..., our launcher and all applications started from that launcher, ...) should now be scaled with the specified factor.

Please note that most linux systems only support scaling with integer values (e.g. 2), and fractional values (e.g. 1.6) might not be supported/lead to weird visualization.

For experts: Framework specific VM variables

These VM variables can be used e.g. during development via Eclipse run configs, or when you want to start only certain applications like this.

webstart https://websvcpro.acc.gsi.de/groups/fcc/applications/scheduling-app.zip --config=pro --vmargs="-Dglass.gtk.uiScale=2"

Swing

-Dsun.java2d.uiScale=2

JFX

-Dglass.gtk.uiScale=2

-- AnnekeWalter - 27 Jul 2023
Topic revision: r1 - 27 Jul 2023, AnnekeWalter
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback