0

I have build a JavaFX application which can be executed by its jar file. However if i try to run it using the native exe bundle i am receiving two popups:

Error Invoking method

Failed to launch JVM

and the application fails to start.

The Javafx application is build with intellij ide.

The project structure looks as follows;

enter image description here

when launching the application following popup shows.. enter image description here

enter image description here

The config file looks as follows:- enter image description here

The packaged jar file is executing properly... the problem occurs when starting application with launching exe file. kindly tell me what could went wrong?

UPDATE: It seems that the build output runtime/bin directory does not contain java.exe file therefore i think the application does not launches. the output when try to run the application is as follows:

enter image description here

i have build the application with intellij idea, i think there is a problem with that. Kindly look into this matter.

UPDATED:-

enter image description here

Ranjit Vamadevan
  • 514
  • 5
  • 21

1 Answers1

0

Run it from the command line using the runtime that was bundled for you:

If you made an executable Jar (with a proper manifest specifying the classpath and main class)

cd firecap
runtime\bin\java -jar app\libs\your-main.jar

If you don't have an executable jar use something like

cd firecap
runtime\bin\java -cp app\libs\*.* your.main.class.name

Since java.exe is a console program you should be able to see the full error output to get a better idea of what is going wrong.

You very likely have missed including a needed module in the runtime.

It is also possible you ran into a bug that I discovered recently: https://bugs.openjdk.java.net/browse/JDK-8254920

I created my runtime image with this command:

"C:\Program Files\BellSoft\LibericaJDK-15-Full\bin\jlink.exe"  --no-header-files --no-man-page, --compress=1 --add-modules java.management,java.logging,javafx.controls,java.xml,java.desktop --output C:\MyProject\build\image\runtime

But yours may be different depending on what modules you need. Note also that I used a JDK from BellSoft that included the JavaFX modules to make it easier.

swpalmer
  • 3,890
  • 2
  • 23
  • 31
  • As you said i have run the application and it is not working and when i checked the bin directory there is no java.exe application file. i think the application is crashing because of that. I think the intellij idea did not build the application properly. how can i overcome this problem. – Ranjit Vamadevan Nov 14 '20 at 13:24
  • There doesn't have to be a java.exe in the runtime\bin folder. If jpackage is used, it's launcher exe is used and java.exe isn't required. If you have access to the jpackage options add --win-console so you can easily see the error messages. – swpalmer Nov 14 '20 at 18:52
  • Is there a build log you could share, or specific configuration options? I don't use Intellij Idea (I find it requires too much configuration to make it work well), so I don't know specifically what it is trying to do. If you had a Gradle build file or something like that it would be helpful. – swpalmer Nov 14 '20 at 18:55
  • sir can you provide me with some links so that i can use gradle to build and deploy javafx. – Ranjit Vamadevan Nov 15 '20 at 13:21
  • i have tried everything from openjfx but not working because i have a little knowledge about gradle. – Ranjit Vamadevan Nov 16 '20 at 09:32
  • i have multiple jdk's installed i am not able to set jdk 15 for gradle. – Ranjit Vamadevan Nov 16 '20 at 09:33
  • Set the JAVA_HOME environment variable to point to your JDK 15 directory and Gradle will use it for the builds. You could start by running jlink and jpackage manually after creating your application jar and folder of dependency jars. Read Gradle docs for the application plugin to get started with that. – swpalmer Nov 17 '20 at 03:05
  • i am getting - Task :app:prepareModulesDir FAILED and Unsupported class file major version 59 – Ranjit Vamadevan Nov 18 '20 at 16:27
  • Please help me in creating the runtime. – Ranjit Vamadevan Nov 18 '20 at 16:28
  • @RanjitVamadevan so you are running your program on an older version of the JRE than what you compiled with and the class file format has changed between those versions. – swpalmer Nov 18 '20 at 16:29
  • my toolchain is java15 – Ranjit Vamadevan Nov 18 '20 at 16:31
  • sir i have added updated screenshot https://i.stack.imgur.com/4vIrV.png – Ranjit Vamadevan Nov 18 '20 at 16:37
  • @RanjitVamadevan I've edited the answer to include an example of running jlink to create a JRE image. – swpalmer Nov 18 '20 at 16:39
  • @RanjitVamadevan You must be running with JRE 14 or earlier to get that error. https://stackoverflow.com/questions/9170832/list-of-java-class-file-format-major-version-numbers – swpalmer Nov 18 '20 at 16:42
  • When creating image with jlink with gradle i am getting exception. FAILURE: Build failed with an exception. – Ranjit Vamadevan Nov 26 '20 at 13:40
  • What went wrong: Execution failed for task ':app:prepareModulesDir'. > Unsupported class file major version 59 – Ranjit Vamadevan Nov 26 '20 at 13:40
  • "Unsupported class file major version 59" You are mixing different versions of Java, or using tools that don't support the version you are using. Your classes are compiled with a newer version of Java than the tool that generated that error can handle. Use the latest Gradle and make sure you aren't mixing JDK versions. – swpalmer Nov 27 '20 at 15:11