Java FileChooser GLib-GIO-ERROR

I am writing a program with Javafx jdk 21 Right now, when using the file chooser I get the following Error:

(java:3334): GLib-GIO-ERROR **: 16:00:31.682: No GSettings schemas are installed on the system

I installed jdk21 with javafx like this:

programs.java = {
    enable = true;
    package = (pkgs.jdk21.override { enableJavaFX = true; });
  };

I am on Hyprland, I did something like this before already like 6 months back and it worked perfectly fine, how can Iinstall the GSetting schemas, I already tried to simply add gsettings-desktop-schemas to my environment.systemPackages.

If I start intellij from the terminal and try to run it I get a slightly different error:

(java:26703): GLib-GIO-ERROR **: 16:56:26.574: Settings schema 'org.gtk.Settings.FileChooser' is not installed

Admittedly this is a bit hacky, but try adding this into your NixOS config:

environment.sessionVariables.XDG_DATA_DIRS = [
  "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}"
  "${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}"
];
1 Like

Some prior context here as well

Just for future reference of anyone having the same problem in future (I had the same issue but with prismlauncher)

Here’s a home-manager module that does this specifically for the binary in a more contained way rather than setting it system wide

{ pkgs, ... }:

let
  prismlauncher-wrapped = pkgs.symlinkJoin {
    name = "prismlauncher-wrapped";
    paths = [ pkgs.prismlauncher ];
    nativeBuildInputs = [ pkgs.makeWrapper ];

    postBuild = ''
      wrapProgram $out/bin/prismlauncher \
        --set XDG_DATA_DIRS "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}"
    '';
  };
in
{
  home.packages = [ prismlauncher-wrapped ];
}