Java App in Flatpak Can't Execute Command From .var/app/APP_ID/ Filesystem - "No such file or directory"

Hello everyone,

I’m trying to package an Open Runescape Classic launcher called OpenRSC. Unfortunately, I’m getting the following exception that doesn’t happen outside of Flatpak: Cannot run program "java" (in directory "/home/wacket/.var/app/vet.rsc.OpenRSC.Launcher/extras/winrune/WinRune-master"): error=2, No such file or directory
	at java.base/java.lang.ProcessBuilder.start(
	at java.base/java.lang.ProcessBuilder.start(
	at java.base/java.lang.Runtime.exec(
	at java.base/
Caused by: error=2, No such file or directory
	at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
	at java.base/java.lang.ProcessImpl.<init>(
	at java.base/java.lang.ProcessImpl.start(
	at java.base/java.lang.ProcessBuilder.start(
	... 4 more

Looking at the source code, OpenRSC Launcher does the following steps:

  • Downloads the game client
  • Uses some CmdRunner (which takes a command and path to run the command on) to run java -jar /home/wacket/.var/app/vet.rsc.OpenRSC.Launcher/extras/winrune/WinRune-master inside the /home/wacket/.var/app/vet.rsc.OpenRSC.Launcher/extras/winrune/ directory

Based on the stacktrace, it seems CmdRunner can’t enter the /home/wacket/.var/app/vet.rsc.OpenRSC.Launcher/extras/winrune/ directory (although the directory exists on my system; I can cd into it).

Does anyone have any ideas on what I can do to make this work? I’m new to using Flatpak as a dev so I could be overlooking something simple.

Some things I’ve tried -

  • Granting full filesystem access
  • Using subdirectories inside .var/app/APP_ID/, such as data or cache
  • Not using .var/app/APP_ID to store the client’s downloads, and using filesystem access to specific folders instead

As an aside, it seems to be able to download files into the directory and detect them no problem. It just can’t run java from inside the directory

I have a copy of the Flatpak on my Github here if anyone wants to see specifics

Reading the stack more closely, it says Cannot run program java… Perhaps it’s referring to not being able to find “java”, rather than not being able to find the directory.

As part of my finish-args, I have

    "finish-args": [

But perhaps that doesn’t necessarily mean it knows where java is. Not sure if this is a lead yet, but posting per-emptively as I debug

Got it working! The answer was that it couldn’t find java, not that it couldn’t find the directory.

Java installs by default to /app/jre/bin, so you have to set env in the finish args to include it:

  • /usr/bin is included since that’s where all the default exec things are, not sure if it’s needed but might as well
  • /app/bin is where my build is going, so that needs to be in the path
  • /app/jre/bin is where the java bin lives, so you need that to run Java

You also no longer declare the JAVA_HOME env since you can just invoke java now.

Hopefully this helps someone else too =)