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

Mac OS: Image compiles and runs, but no display. #86

Closed
xcporter opened this issue Aug 26, 2020 · 7 comments
Closed

Mac OS: Image compiles and runs, but no display. #86

xcporter opened this issue Aug 26, 2020 · 7 comments

Comments

@xcporter
Copy link

Hello!

I've using version 1.31 of the plugin with JavaFx 11.

When I compile and run a native image, the executable runs, but no window is displayed.
In the command line I get the following exceptions:

java.lang.RuntimeException: Unable to construct Application instance: [application class name]
Caused by: java.lang.NoSuchMethodException: [application class name].()

One possible reason might have to do with the fact that it's written in Kotlin with TornadoFx.

I've tried modifying the launch method to use more java-like conventions, but to no avail.

Any idea what might be causing this?

@jperedadnr
Copy link
Collaborator

See related issue: gluonhq/substrate#572

You can see that you have to add the classes from the main application class to the reflection list.

@xcporter
Copy link
Author

Thank you!

How does this configuration look in gradle?

At this point, I'm trying to add it to the gluonPlugin as a list of strings, but now it won't compile

gluonClient {
       reflectionList = [
            "org.test.AdminApp",
            "org.test.MainView",
            "org.test.AdminStyle"
           ...
    ]
}

@jperedadnr
Copy link
Collaborator

That should work. What error do you get?

@xcporter
Copy link
Author

After a little more checking I just had some references wrong, so the reflection list is working.

I followed a few different error paths and ended up resolving a few more "unsupported feature" errors by rearranging code.

I can get a basic app to display nicely, but there are a few remaining hangups:

--it doesn't seem to pick up the TornadoFX stylesheet class, but no big deal since inline style is working just fine.

--it can't seem to find the JavaFx resources necessary to instantiate a media player
(java.lang.NoClassDefFoundError: javafx/scene/media/Media)

I'm including the media module with the openjfx gradle plugin like this:

javafx {
    version = "11"
    modules = [ 'javafx.controls', 'javafx.media', 'javafx.fxml']
}

Should I be including some kind of additional arguments for native image regarding javafx.media?

@jperedadnr
Copy link
Collaborator

What extension is your style class, css?
Media is not supported yet.

@xcporter
Copy link
Author

The css is a tornadofx construct--no extension on the file, but the css is stored in a class like this:

class Style : Stylesheet() {
    companion object {
        //css rules declared here and delegated, then defined in the init block
    }
}

Then it's compiled with type safety. Though, it doesn't seem to be working with inline style either now that I look.

For some reason I thought I could get away with javaFX media player if the target was desktop--not sure where I got that idea actually. I suppose I'll look into the charm-down plugin, or libVLC or something.

If it works with the css migrated to actual css files, I might just go that route. Reformatting a few files is a small price to pay for a nice binary.

Thank you for all your amazing help!

@jperedadnr
Copy link
Collaborator

If the css class is used reflectively, try adding it to the reflectionList as well. That might work. Migrated to .css should work too, of course.

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

No branches or pull requests

2 participants