Java on Librem 5

I see the same thing on the Librem 5, FWIW. This would be way down my list of obstacles to achieve as per the topic subject however.

Command line Java code works ‘as is’ on the Librem 5. Just copy the binary over. Job done. It’s only the GUI that steadfastly refuses to operate on the Librem 5. I didn’t try too hard to get it going though.

2 Likes

FWIW I wrote this program which uses swing to display a UI with buttons and it works fine. (it’s a remote for controlling Zoom running on my laptop during my online yoga classes :blush:) No fancy OpenGL stuff in it though.

5 Likes

As a random thought on this topic, it may be worth noting that so far all of my LibGDX Java games written for desktop have worked flawlessly on the Librem 5. These are systems that use lwjgl (jni wrappers on OpenGL, glfw, etc) to display visuals.

So, the only issue we are having is presumably due to a very specific issue with AWT and how it integrates with Phosh. I recall doing some tests and JOptionPane worked fine but JFrame did not, at least in some cases. I don’t know more than that yet.

6 Likes

I built your client program for my desktop and it runs and displays. Unfortunately it can’t do anything (yet) because the remote doesn’t exist. I’ll dummy up something for the remote and configure that into the web server on my VPS. Am I right in thinking that, for this purpose, the server doesn’t have to do anything or return anything in particular? So a polite web server would be listening on the right port, accept all POST requests and return a valid HTTP response of 200 with e.g. text/plain, length 2, “OK” and the client will be happy?

If that works, then I might try the client on my Librem 5.

One thing that may be a problem with other Java programs that I have tried on the Librem 5 is that those programs rely on a menu bar, with mnemonics and accelerators (in other words, it’s really designed for a classic desktop environment). They also don’t have an explicit “exit” option - so without the title bar there is no X to close the application. :frowning: (By contrast, your program is using buttons.)

I should try when docked. That may give a more normal default UI.

For comparison, what Java version do you have on the Librem 5?

The program linked above by @tendays is using a JFrame and it reportedly works. I’m using a JFrame and getting inconsistent results: some things fail to function at all, some things work intermittently.

1 Like

Not sure I understand what you mean… The client and the remote is the same application (just put --server to run as server. It expects a /usr/bin/xdotool executable for actually sending mouse and keyboard events). Anyway the client doesn’t care at all what the server returns or even whether there is a server at all, I did the very least I could to have something that does the job :slight_smile:

Pull the window up in overview mode? Or is that different from clicking the X from the app’s point of view?

purism@pureos ~ % java -version
openjdk version "17.0.10" 2024-01-16
OpenJDK Runtime Environment (build 17.0.10+7-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.10+7-Debian-1deb11u1, mixed mode, sharing)
2 Likes

Right, yep I got that. But let’s say I don’t want to run the server - just the client - because it’s the client that may be troublesome on the Librem 5. I was just looking to put up a dummy server. Anyway you confirmed what I needed to know.

I think though that you want: fail fast or succeed fast.

What you don’t want is a bunch of threads all sitting there timing out their HTTP requests - in case that causes resource issues on the Librem 5. (Hence, for example, I want the DNS request for the domain name to succeed or otherwise fail fast, rather than counting out the normal number of DNS retries and timeouts. And similarly with the HTTP requests.)

Exactly. There’s no way to tell. There are so many layers of software involved …

I’ll investigate that and report here if I can confirm. For me though it was more about the UX.


One option I might try, as my first foray into “adaptability”, is that the code that builds the menus, when so configured, will build buttons (or similar) instead.

OK, mine’s fairly out of date, as well as some of the other problems that I am having.

1 Like