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
Native Image of simplest Java Swing Application #2644
Comments
Hi @hanns-maulwurf, |
Hello @fniephaus, |
That's right. If this is not what you want, you either have to wait or use a different UI framework. IIRC JavaFX is somewhat supported. |
Na, another UI framework is too much effort, just to get a native image. Or does anyone else has some other suggestions, that could bring that simple Swing Appliation to work with native-image? |
@hanns-maulwurf I tried your example and it worked on my machine |
Java Bug https://bugs.openjdk.java.net/browse/JDK-8130266 should help fix this issue which was delivered in JDK13. |
You can compile the example (HelloSwing.java) I provided above to a native image and execute it and you get the "Hello Swing App" window shown? As I said, I can compile without error, but running the native image produces an IllegalArgumentException ("AWT is currently not supported on Substrate VM"). What GraalVM version etc did you use for that and on what system did you compile/run it? I do not have a more complex example, because if I can't run even the simplest application, there is IMO no benefit in creating one. If the provided example runs at your machine, than I should figure out first why it doesn't run on my machine? |
OK, that would be great. Unfortunately there is as far as i see no GraalVM that is based on JDK 13 or newer. The latest nightly-build is also based on JDK11. Or is there somewhere a GraalVM build with JDK 13? |
Hello @hanns-maulwurf, I just built and executed your example without issues.
Used: |
Hello @mcraj017 and @fernando-valdez , If you build it like that, this will generate a fallback image. In the output from the native-image command it states:
If you then add the --no-fallback parameter you will first get errors (at least I do), because it can't resolve some stuff.
With this command line I was able to build the image with the --no-fallback option, but running the resulting image produced the error I described in this issue. So a fallback-image is not what I am looking for, because then I will have to bundle the .class files and a JDK with the application which is what I wanted to avoid and what was the point of the whole thing. Or am I getting something wrong here for example what a fallback-image is? |
@hanns-maulwurf Check this ticket #1327, |
Closing the issue as this will be resolved once graalvm have support for jdk 13 or latter |
@mcraj017 When will JDK 13 be supported? |
@ScottPierce next release 21.1 will have eperimental support for Java 16 |
A "hello world" example via swing + native-image on the official documentation would be super-useful IMO. Does not have to be a complicated GUI, just something we can quickly compile via native-image and then |
Describe the issue
I am trying to build a native executable out of a Java Swing application with the GraalVM native-image command.
As I did get so many errors I couldn't solve at first, I decided to just try a simple Hello-world style example app first, because if I couldn't get this to work, I don't have to bother trying a much more complex application.
And as it turned out, I can't get it to work, so this is why I am asking here what I might be doing wrong or if native-image can't handle Swing applications at all (in which case I would not need to spend any more time with this).
My progress so far:
I could get native-image to build an exe from the HelloWorld Swing app.
But when I run the exe, I get the following error:
Steps to reproduce the issue
The code of the HelloSwing program is very simple:
I first compiled the HelloSwing.java class with the GraalVM javac command.
Then I called native-image from the Visual Studio 2019 x64 Native Tools Command Prompt with the following parameters:
Rational for the used options:
Describe GraalVM and your environment:
So my question(s) are:
Is it just not possible, to make a native image of an Swing application?
Has anyone here ever successfully built an exe of a Swing application that worked (even if just a HelloWorld example)?
Or am I doing something wrong here?
Any hints/comments appreciated.
More details
Here is the output of the native-image command with --verbose and --native-image-info turned on:
The text was updated successfully, but these errors were encountered: