B4J Question Running Jar File with OpenJDK Error

walterf25

Expert
Licensed User
Longtime User
Hi Everyone, I have been trying to find a way to make a project distributable for a couple of months, I am able to create an .exe file using the B4JPackager tool and Inno Setup, but for some reason I get some errors that I do not get when I run the project from within B4J, here's the thread for more context.

@Erel suggested I distribute the jar file along with OpenJDK and a batch file to launch the jar file, I have created the following batch file
batch file:
@ECHO OFF
TITLE RUN A JAR FILE
CD C:\Java\jdk-14.0.1\bin
javaw --module-path C:\Java\jdk-14.0.1\javafx\lib --add-modules ALL-MODULE-PATH -jar "C:\Users\wflores\Documents\B4J_Projects\WindowsCompanion\B4J\Objects\WindowsCompanion.jar"
::PAUSE

That batch file actually launches the Jar file, but I get this error right away and then the jar file closes.

I have added these two lines to the project in hopes of fixing this issue, but doesn't work.

Added Lines:
    #VirtualMachineArgs: --add-opens javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED
    #VirtualMachineArgs: --add-exports javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED

Does anyone know what else I can try, It is frustrating that it is so difficult to find a solution that can finally allow me to distribute this file, it is very trivial as I am on a deadline here at work, maybe I should have done this using a different platform, but lesson learned, as I have no more time I need to find a solution.

Thanks everyone
Walter
 
Last edited:

Daestrum

Expert
Licensed User
Longtime User
maybe you need to add the lines to #PackagerProperty too
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
maybe you need to add the lines to #PackagerProperty too
So, I tried adding this line also
B4X:
#PackagerProperty: AdditionalModuleInfoString = exports com.sun.javafx.geom;

But I still get the same error, any suggestions?

Walter
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I was thinking more the
B4X:
.

#PackagerProperty: VMArgs = --add-opens ...
you best check as I don't remember the format for it
 
Last edited:
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Just noticed in your original post, you are using javac - that's for compiling, you want java to run the jar (or javaw for no cmd window)
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Just noticed in your original post, you are using javac - that's for compiling, you want java to run the jar (or javaw for no cmd window)
Yes, I realized that too and also tried java and javaw, but doesn't make a difference as far as the error goes.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
So I was able to launch the jar file with the following command
Batch File:
C:\Java\jdk-11.0.1\jdk-11.0.1\bin\java --module-path C:\Java\jdk-11.0.1\jdk-11.0.1\javafx\lib --add-modules ALL-MODULE-PATH --add-exports javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED --add-opens javafx.graphics/javafx.scene.canvas=ALL-UNNAMED -jar .\jar.jar

Walter
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Did you try putting the add-opens on the

#PackagerProperty: VMArgs = --add-opens javafx.graphics/javafx.scene.canvas
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Did you try putting the add-opens on the

#PackagerProperty: VMArgs = --add-opens javafx.graphics/javafx.scene.canvas
Yes but this is only required if I want to create an executable, I have tried this already but while the jar file works fine, when I create an executable I get some other error which is why I am trying to distribute just the .jar file.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…