Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide flatpak #1190

Closed
plata opened this issue Mar 14, 2018 · 11 comments · Fixed by #1406
Closed

provide flatpak #1190

plata opened this issue Mar 14, 2018 · 11 comments · Fixed by #1406

Comments

@plata
Copy link
Collaborator

plata commented Mar 14, 2018

general flatpak tutorial: http://docs.flatpak.org/en/latest/first-build.html

old flatpak tutorial for Java apps: https://github.com/flatpak/flatpak.github.io/blob/81bb006fd96b9a13170bd876316eb5a4eb48244b/source/bundling-a-java-app.html.haml.markdown

good example (pycharm): https://github.com/flathub/com.jetbrains.PyCharm-Community/blob/f9e57ce185a4c2f6a171f9e5b5f3ba2acd36a475/com.jetbrains.PyCharm-Community.json

@LukeShortCloud
Copy link
Contributor

There used to be an official document on how to bundle Java applications with Flatpak.

flatpak/flatpak-docs#17

It was removed because some of the information was outdated (and apparently no one remembers why).

The original documentation can still be found in Flatpak's GitHub history, as noted in the above GitHub issue. It could probably be used as a starting point.

https://github.com/flatpak/flatpak.github.io/blob/81bb006fd96b9a13170bd876316eb5a4eb48244b/source/bundling-a-java-app.html.haml.markdown

I actually wanted to open up a feature request for packaging Phoenicis as a Flatpak so you beat me to it! I'm glad to see you guys are open to embracing a cross-platform packaging platform that's mature and secure. ;-)

@plata
Copy link
Collaborator Author

plata commented Mar 17, 2018

I've actually tried to build a flatpak. However, I didn't quite succeed. My main issue was: flatpak/flatpak-builder#58 (I see that the tutorial uses a pre-built binary).

I must admit that I have absolutely no experience with flatpak so if you manage to get something working you're very welcome to share it here.

@LukeShortCloud
Copy link
Contributor

It appears that Maven isn't installed by default in any of the available run-time environments. Adding that will have to be part of the Flatpak build instructions for Phoenicis. https://maven.apache.org/install.html

An extension, such as this one for OpenJDK 1.9, will also need to be used with the Flatpak to provide Java in the run-time environment.

I honestly do not have much real-world experience with Flatpak, either, besides being an end-user/consumer of it. I would love to use it more for packaging. As a Python developer, most of my needs are handled by packaging for PiPy (pip) and using docker containers.

@plata
Copy link
Collaborator Author

plata commented Mar 19, 2018

I think with the current environment available, it is too complicated to build the flatpak from the sources. Using a pre-compiled .jar is more realistic in my opinion.

@LukeShortCloud
Copy link
Contributor

You're probably right. Sticking with a single distributable Jar file might make more sense. Depedencies would still have to be handled by other means. I know there's DEB packaging support in here already. I could work on creating an RPM for Fedora and CentOS/RHEL. As opposed to Flatpak, I have extensive experience with packaging using RPM.

@plata
Copy link
Collaborator Author

plata commented Mar 22, 2018

That would be great! If possible integrated in the Maven build.

@plata
Copy link
Collaborator Author

plata commented Sep 16, 2018

{
    "app-id": "org.phoenicis.javafx",
    "runtime": "org.freedesktop.Platform",
    "runtime-version": "1.6",
    "sdk": "org.freedesktop.Sdk",
    "command": "phoenicis-javafx",
    "sdk-extensions": [
        "org.freedesktop.Sdk.Extension.openjdk9"
    ],
    "finish-args": [
        "--share=ipc",
        "--socket=x11",
        "--share=network",
        "--filesystem=host",
        "--env=PATH=/usr/bin:/app/bin:/usr/lib/sdk/openjdk9/bin"
    ],
    "modules": [
        {
            "name": "javafx",
            "buildsystem": "simple",
            "build-commands": [
                "install -D phoenicis-javafx /app/bin/phoenicis-javafx",
                "install -D phoenicis-javafx-5.0-SNAPSHOT-jfx.jar /app/phoenicis/phoenicis-javafx.jar",
                "cp -r lib /app/phoenicis"
            ],
            "sources": [
                {
                    "type": "dir",
                    "path": "phoenicis-javafx/target/jfx/app"
                },
                {
                    "type": "script",
                    "dest-filename": "phoenicis-javafx",
                    "commands": [
                        "cd /app/phoenicis",
                        "java -jar phoenicis-javafx.jar \"$@\""
                    ]
                }
            ]
        }
    ]
}

This gives me:

Error: Could not find or load main class org.phoenicis.javafx.JavaFXApplication
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

Hint: you might need a newer flatpak-builder version than provided by default to use "type" : "dir" (there's a PPA: ppa:alexlarsson/flatpak).
Hint 2: if you cannot compile after playing around with flatpak, ensure that your checkout is clean (e.g. git clean -fdx). It might be sufficient to remove the build dir and .flatpak-builder.

@plata plata mentioned this issue Sep 16, 2018
@madoar
Copy link
Collaborator

madoar commented Sep 16, 2018

I guess you flatpak uses Java 9?
As far as I remember OpenJDK 9 belonged to the Java versions for which we discovered integration problems with JavaFX, right?

I see two solutions for the problem:

  1. try again with Java 8
  2. wait for Java 11, which supports another integration scheme for JavaFX

@plata
Copy link
Collaborator Author

plata commented Sep 16, 2018

There was a problem with OpenJDK 9 but I'm not sure if it explains this issue. Seems to be much more general for me than JavaFX. I cannot use Java 8 because there's no extension for it.
Update: Ok, seems like this is indeed the issue: https://www.reddit.com/r/javahelp/comments/4ucutf/running_my_java_8_jar_on_a_java_9_jre/

@plata
Copy link
Collaborator Author

plata commented Sep 16, 2018

@alexlarsson is it correct that the OpenJDK 9 extension cannot run JavaFX apps or am I doing something wrong?

@plata
Copy link
Collaborator Author

plata commented Sep 16, 2018

{
    "app-id": "org.phoenicis.javafx",
    "runtime": "org.freedesktop.Platform",
    "runtime-version": "1.6",
    "sdk": "org.freedesktop.Sdk",
    "command": "phoenicis-javafx",
    "finish-args": [
        "--share=ipc",
        "--socket=x11",
        "--share=network",
        "--filesystem=host",
        "--device=dri"
    ],
    "modules": [
        {
            "name": "javafx",
            "buildsystem": "simple",
            "build-commands": [
                "install -D phoenicis-javafx /app/bin/phoenicis-javafx",
                "cp -r phoenicis-javafx-5.0-SNAPSHOT /app/phoenicis",
                "chmod 755 -R /app/phoenicis"
            ],
            "sources": [
                {
                    "type": "dir",
                    "path": "phoenicis-javafx/target/jfx/native"
                },
                {
                    "type": "script",
                    "dest-filename": "phoenicis-javafx",
                    "commands": [
                        "/app/phoenicis/phoenicis-javafx-5.0-SNAPSHOT \"$@\""
                    ]
                }
            ]
        }
    ]
}

Using this with the native bundle gives me:

phoenicis-javafx-5.0-SNAPSHOT Error invoking method.
phoenicis-javafx-5.0-SNAPSHOT Failed to launch JVM

Update: It kind of works with

"runtime": "org.gnome.Platform",
"runtime-version": "3.28",
"sdk": "org.gnome.Sdk",

I think the main problem is that the native Linux build depends on the system it is built on. That's also causing issues when using Phoenicis. So this is probably not really an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants