Java-gtk: GTK 3 bindings for Java

Available on GitHub:

This project consists of a code generator written in Kotlin, the library itself and some examples.

For more complex examples see this weather forecast application written in Kotlin: and a Mapsforge to GTK port: (also available on my GitHub account, but unfortunately I’m out of links…)

Instructions on how to generate and compile the library are in the projects README and CI configuration.

So far I have compiled and tested this project on debian testing AMD64 and debian testing (mobian) on a PinePhone (aarch64).

A compiled library is also available as a build artifact from CI (GitHub actions)

java-gtk is meant for testing, there is no release yet.


That’s pretty cool. It’s a shame the community isn’t showing much interest, because the infrastructure could really benefit from good bindings for a language like Java. C# would also be good, especially if it resulted in a solid Linux version of MAUI, but there seems to be not just apathy, but hostility between GTK/GNOME and C# developers.

I see the amount of code in the ‘library’ section is quite small, so would it be quite easy to support GTK4? How about other major GI libraries like gstreamer?

That is categorically untrue, unless you’re cherry picking behaviour from 15 years ago, when the world was very different.

Not every language is equally distributed through the community; the C++ and Perl bindings were the first GTK language bindings ever written, but you won’t see many Perl or C++ applications; C# bindings have been languishing for a long time, mostly because they were developed in house at Novell pre-Xamarin, and there isn’t a large community behind them. There used to be a whole set of Java bindings, but the transition from GNOME 2 to GNOME 3 coincided with a loss of maintenance, and nobody picked them up.

In practice: maintaining language bindings is not entirely trivial, but it has no bearing on whether or not people pick up a language for writing a GNOME application.

We probably are referring to the same thing. ISTR the people behind Xamarin blamed hostility from other Linux users for their abandonment of the platform. By GTK/GNOME developers I don’t just mean official developers of those technologies, but 3rd party developers. That said, I know you get a lot of criticism in general, a lot of it unfair, even now.

Although .NET for Linux is supported by Microsoft now, it’s still really based on Mono isn’t it? Are those same people with negative views about GTK and its community still involved? And I think there is still a strong anti-Microsoft feeling despite great projects like Typescript and VS Code. And other branches of MS are giving people good reason to distrust them eg their attempts to force people to use Edge have become quite aggressive.

Am I right in thinking GTK# is/was mostly written by hand? I’ve seen a version for GTK3, but I don’t know whether they just updated the existing handwritten code or did some major re-engineering so that the bulk of the bindings can be generated from GI. Although every language needs a different set of foundations to wrap GObject etc, I think a lot of the work in parsing GI, such as @bailu has done, could be shared between them.

I’m not sure of your point here. I think Linux desktops will struggle to survive unless it becomes easier to port applications between it and other platforms, especially Windows, without the Linux version looking and behaving like it’s more than a decade out of date and/or substantially alien to GNOME. Flutter will help, but it’s not suitable for all types of application.

There is now a GTK 4 branch. Porting the library to GTK 4 was surprisingly easy.
The difficult part was adjusting the examples and figuring out the new API :wink:.

As soon as I have ported my apps to GTK 4 I’ll merge this into main.

At least in theory expanding to other libraries should be feasible.
But I must admit my knowledge about GTK and GNOME is too limited to make any predictions.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.