-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add graalvm-native image support! #88
Comments
We're 100% reliant on AWT, so if that's something that doesn't mesh with GraalVM, I doubt we'd ever be able to support it. This library basically just wraps the AWT calls in a way that's intuitive for JavaFX developers. |
AWT or SWING is not supported yet on But in case of this project, still I am facing issues!
process-run until end-1723000330575.log | client-debug0.log Steps to reproduce it:
|
I've had success with AWT in Java making native-images when I create a FAT JAR file using the Maven Assembly Plugin. I then run the fat jar doing something like this:
Then you engage the program everywhere it makes calls to AWT that way the libraries are included in the
I have several programs that use FXTrayIcon compiled into native-images. If you need any example POM file configs, let me know. Mike |
@EasyG0ing1 Thanks! Can you provide me more info! |
I have tried another one, but still issues and issues:
the building process:
|
Here is the POM file for an app I wrote for myself that uses only FXTrayIcon as the interface with some JavaFX screens that pop out from some menu selections: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.simtechdata</groupId>
<artifactId>SimpleOTP</artifactId>
<version>1.0</version>
<name>SimpleOTP</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javafx.version>22</javafx.version>
<source.target.release>22</source.target.release>
<maven-compiler-plugin>3.13.0</maven-compiler-plugin>
<maven-jar-plugin>3.4.2</maven-jar-plugin>
<maven-enforcer-plugin>3.5.0</maven-enforcer-plugin>
<maven-assembly-plugin>3.7.1</maven-assembly-plugin>
<maven-dependency-plugin>3.8.0</maven-dependency-plugin>
<exec-maven-plugin>3.2.0</exec-maven-plugin>
<exec.domain>com.simtechdata</exec.domain>
<mainClass>com.simtechdata.Main</mainClass>
<javapackager>1.7.5</javapackager>
<gluonfx-maven-plugin>1.0.22</gluonfx-maven-plugin>
<javafx-maven-plugin>0.0.8</javafx-maven-plugin>
<gluonfx.target>22</gluonfx.target>
<moditect-maven-plugin>1.2.1.Final</moditect-maven-plugin>
<versions-maven-plugin>2.17.1</versions-maven-plugin>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>com.simtechdata</groupId>
<artifactId>EasyFXControls</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.simtechdata</groupId>
<artifactId>GoogleAuthDecoder</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.simtechdata</groupId>
<artifactId>OTPURI</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>6.3.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>com.dustinredmond.fxtrayicon</groupId>
<artifactId>FXTrayIcon</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>com.google.crypto.tink</groupId>
<artifactId>tink</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.12.0</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.hildan.fxgson</groupId>
<artifactId>fx-gson</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.15.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>Gluon</id>
<url>https://nexus.gluonhq.com/nexus/content/repositories/releases</url>
</repository>
</repositories>
<build>
<plugins>
<!--Maven Versions-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>${versions-maven-plugin}</version>
<executions>
<execution>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
<goal>property-updates-report</goal>
<goal>dependency-updates-report</goal>
<goal>plugin-updates-report</goal>
<goal>update-properties</goal>
<goal>use-latest-versions</goal>
</goals>
</execution>
</executions>
</plugin>
<!--Maven Enforcer Plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven-enforcer-plugin}</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>4.0.0-beta-3</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!--Maven Compiler-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin}</version>
<configuration>
<source>${source.target.release}</source>
<target>${source.target.release}</target>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<!--Maven Jar-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin}</version>
<configuration>
<skipIfEmpty>true</skipIfEmpty>
<archive>
<manifestEntries>
<Main-Class>${mainClass}</Main-Class>
<Automatic-Module-Name>${artifactId}</Automatic-Module-Name>
<Program-Version>${project.version}</Program-Version>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!--Maven Dependency Plugin - for collecting modules-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/modules</outputDirectory>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> And here are the scripts that I use to create the native image: First, this script creates all of the necessary json files for the native-image build: #!/bin/bash
JP="$HOME/JetBrainsProjects/IntelliJIdea/SimpleOTP"
G="$JP/graalvm"
T="$JP/target"
mvn -f $JP/pom.xml clean
mvn -f $JP/pom.xml install
java \
--enable-preview \
-agentlib:native-image-agent=config-merge-dir=$G \
--module-path $T/SimpleOTP-1.0.jar:$T/modules \
-m SimpleOTP/com.simtechdata.Main graalvm
java --enable-preview --module-path target/SimpleOTP-1.0.jar:target/modules -m SimpleOTP/com.simtechdata.Main When I run that script, I engage the program and all of the features that implement the various calls so that they get included in the json files. The Maven Dependency Plugin creates a folder in target that contains all of the dependency libraries that the program uses, which I include in the running of the jar file using the Next, I compile the native image like this: #!/bin/bash
JP=$HOME/JetBrainsProjects/IntelliJIdea/SimpleOTP
G=$JP/graalvm
T=$JP/target
mvn -f $JP/pom.xml clean install
echo "Running native-image"
native-image \
--no-fallback \
--verbose \
--enable-preview \
--module-path $T/SimpleOTP-1.0.jar:$T/modules:$HOME/.m2/repository/org/xerial/sqlite-jdbc/3.45.3.0/sqlite-jdbc-3.45.3.0.jar \
--module SimpleOTP/com.simtechdata.Main \
--initialize-at-build-time=org.sqlite.util.ProcessRunner \
-H:+UnlockExperimentalVMOptions \
-H:+ReportExceptionStackTraces \
-H:JNIConfigurationFiles=$G/jni-config.json \
-H:DynamicProxyConfigurationFiles=$G/proxy-config.json \
-H:ReflectionConfigurationFiles=$G/reflect-config.json \
-H:ResourceConfigurationFiles=$G/resource-config.json \
-H:SerializationConfigurationFiles=$G/serialization-config.json \
-H:Name=$T/SimpleOTP
cp $T/SimpleOTP $HOME/JavaBASH/ I hope that helps... Mike |
@EasyG0ing1 Thanks your provided solutions works like a charm I have a little issue now! On my Windows 10, using run or run-agent, all is working correctly!
Or
But in the case of native-image .exe TrayIconFx drop-down menu show nothing~
@EasyG0ing1 Any idea how to solve it? |
I also be able to use simple java Swing/SWT tryicon in Graalvm native-image runiing~ But still a little bit of issue! when running native-image .exe but javafx running or run-agent runing no issue at all! java --enable-preview --module-path "%T%\SimpleOTP-1.0.jar;%T%\modules" -m SimpleOTP/com.simtechdata.Main |
Can FXTrayIcon be used in GraalVM-Native Image?
I think still FXTrayIcon is dependent upon AWT or Swing Part! It can't be used in Grallvm native-image feature.
Actually I have a project which is based upon Javafx and Gluonfx Plugins which behind the scene uses graalvm native-image feature If someone try to build native-image.
In my app also i need to add system tryicon too!
The text was updated successfully, but these errors were encountered: