Can't make java swing work on manjaro

I made a really basic java program with juste a JFrame and a button on it and the output window came out empty. I’ve been trying to get some help from many places but my code works on any other distro and on windows, I reinstalled jdk and jre, added my jdk bin folder to PATH but it didn’t change anything. I am really out of idea so some help would be really nice. I am running Manjaro Linux. I have another drive with windows but it would really be annoying to switch back and forth just for one single reason

I work daily with manjaro , eclipse and swing. No problems even with grafical swing builder, debugging, restarting while editing …

Please provide some Information on your system:

  • Can you share the small program you wrote ?
  • What version of java do you use ?
  • What error message is provided by java ?
  • Do you use eclipse or another tool ?

here is my code, I am running openjdk version 17.0.1 And I have no error message at all, like none, only a blank window in the output. Also I code with Eclipse

package test;

import javax.swing.JButton;
import javax.swing.JFrame;

public class main {
	public static void main(String[] args) {
		JFrame window = new JFrame();
		JButton button = new JButton("My button");
		window.setSize(600,600);
		window.setVisible(true);
		window.add(button);
	}
}

How did you install your jdk? Via pacman?

I do install everything (!!!) via pacman or trizen
If anything is available via pacman (pamac) or trizen (or another AUR-helper) you should NOT install it any other way.

Arch/manjaro is able to have 10 differnt java-versions installed and is able to switch between them on demand
https://wiki.archlinux.org/title/java

This is my list of installed java-versions:

archlinux-java status                                                                                                                             
Available Java environments:
  java-11-graalvm
  java-11-openjdk
  java-17-openjdk
  java-18-openjdk
  java-7-openjdk
  java-8-graalvm
  java-8-openjdk (default)
  java-9-jdk

One of my Projects:

 public static void main(String[] args) {
      EventQueue.invokeLater(new Runnable() {
         public void run() {
            try {
               Rechner window=new Rechner();
               window.frame.setVisible(true);
            } catch (Exception e) {
               e.printStackTrace();
            }
         }
      });
   }
  1. Use the EventQueue
  2. First construct your frame
  3. Add all elements to the frame
  4. Then at last make it visible

Ok, so I did that, i’ve installed java-17-openjdk, but no changes

well i get the JFrame but no JButton if I try to add one

It is not good to add the button AFTER setting the frame visible

Please try also with java 8

did both those two things and nothing but a blank frame

here the code just in case

package testing;

import javax.swing.JButton;
import javax.swing.JFrame;

public class main {
	public static void main(String[] args) {
		JFrame window = new JFrame();
		JButton button = new JButton("My button");
		window.setSize(600,600);
		window.add(button);
		window.setVisible(true);
	}
}

You did not use the EventQueue

when i try with it I get multiple errors, also I never used it so I don’t really know how it works

The only thing i have set is, _JAVA_OPTIONS

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel

I should put this in my .bash_profile?