B4J Question Open .jar with OpenJDK 11

PatrikCavina

Active Member
Licensed User
Longtime User
I decided to uninstall the previous versions of java and leave only openjdk11.
I reconfigured everything from the environment variables to the IDE configuration path.
My problem now is that once the jar file is created, and I try to open it, it does not run.
If I try running the java program from cmd with the command "java -jar fileName.jar", I get this error:

"Error: JavaFX runtime components are missing, and are required to run this application"

The only solution I found was in this post:
https://www.b4x.com/android/forum/t...ibillity-with-previous-projects.102061/page-3

using the command:

"java --module-path javafxpath\lib --add-modules=javafx.controls -jar fileName.jar"

Is it possible that using openJDK I can no longer execute a jar file simply by double clicking on it, without necessarily having to go through the cmd?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is it possible that using openJDK I can no longer execute a jar file simply by double clicking on it, without necessarily having to go through the cmd?
Check this short tutorial: https://www.b4x.com/android/forum/threads/b4j-v6-80-beta-with-support-for-java-11.99541/

Runnable jars are not supported in Java 11+.

You should create an installer instead.

using the command:

"java --module-path javafxpath\lib --add-modules=javafx.controls -jar fileName.jar"
This command is not correct. It is missing many things.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Just to clarify the above batch file command.

1, my JAVA_HOME is set to my java 11 directory, so I can just use java (D:\java 11.0.2+7\jdk-11.0.2+7\bin)
2, my openjfx modules have an environment variable %PATH_TO_FX% so I can use --module-path=%PATH_TO_FX% (javafx-sdk-11.0.2)

I also must emphasise that the b4jPackager11 is a far better solution to use.
Not only can you run from double click, the resultant file is far smaller than the equivalent jar.
 
Last edited:
Upvote 0

PatrikCavina

Active Member
Licensed User
Longtime User
I don't know if i'm very unfortunate, but:

Executing B4jPackager11 i recive this error:

Exception in thread "main" java.lang.module.FindException: Module java.activation not found, required by java.xml.bind

Using this Json settings:
{
InputJar: "C:/Users/xxx/Documents/B4J/Projects/yyyy/PrintProfiles (Grinder3)/V1.0/Objects/NPP.jar"​
}

And

Executing command found in release_java_modules.txt, i recive this error:

java.lang.module.FindException: Module javafx.swt not found
 
Upvote 0

xulihang

Active Member
Licensed User
Longtime User
I successfully run my jar using the command below which is modified from stackoverflow.

B4X:
E:\jdk-11.0.1\bin\java --module-path E:\jdk-11.0.1\javafx\lib --add-modules javafx.controls,javafx.fxml,javafx.web -jar BasicCAT.jar

But I got this exception which does not show using IDE.

B4X:
(IllegalAccessException) java.lang.IllegalAccessException: class anywheresoftware.b4j.object.JavaObject cannot access class com.sun.javafx.collections.VetoableListDecorator (in module javafx.base) because module javafx.base does not export com.sun.javafx.collections to unnamed module @6935900b
 
Upvote 0

xulihang

Active Member
Licensed User
Longtime User
I check the release_java_modules.txt in B4JPackager11's build and add the following params. And I find the exception is gone, though I don't know what does --add-opens do.

B4X:
--add-opens javafx.controls/com.sun.javafx.scene.control.inputmap=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED --add-opens javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.scene.traversal=ALL-UNNAMED --add-opens javafx.graphics/javafx.scene=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.collections=ALL-UNNAMED --add-opens javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.event=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.css=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.runtime=ALL-UNNAMED --add-opens javafx.controls/com.sun.javafx.scene.control.skin=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED --add-opens javafx.graphics/javafx.scene.canvas=ALL-UNNAMED
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Here's the original parameter provided from RichTextFX on GitHub (from their forum posts)

--add-exports javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED --add-exports javafx.graphics/com.sun.javafx.text=ALL-UNNAMED --add-exports javafx.graphics/com.sun.javafx.scene.text=ALL-UNNAMED --add-opens javafx.graphics/javafx.scene.text=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.text=ALL-UNNAMED
 
Last edited:
Upvote 0

PatrikCavina

Active Member
Licensed User
Longtime User
Now i have better understand logic of openJDK.
But my problem about B4JPackager11 persists. Yesterday i have made a test with another pc, and all work fine.
With my work pc i recived always the same error when i try to package my app:

Waiting for debugger to connect...
Program started.
B4JPackager11 Version 1.02
InputJar: C:\Users\xxx\Documents\B4J\Projects\yyy\PrintProfiles (Grinder3)\V1.0\Objects\NPP.jar
Running: C:\Users\XXX~1\DOCUME~1\B4J\Utils\B4JPAC~1\src\Objects\temp\FindDosPath.exe
Running: C:\Program Files\Java\jdk-11.0.1\bin\jar
Package name: b4j.example
Running: C:\Program Files\Java\jdk-11.0.1\bin\jdeps
.
Exception in thread "main" java.lang.module.FindException: Module java.activation not found, required by java.xml.bind
at java.base/java.lang.module.Resolver.findFail(Resolver.java:877)
at java.base/java.lang.module.Resolver.resolve(Resolver.java:191)
at java.base/java.lang.module.Resolver.resolve(Resolver.java:140)
at java.base/java.lang.module.Configuration.resolve(Configuration.java:411)
at java.base/java.lang.module.Configuration.resolve(Configuration.java:245)
at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration.<init>(JdepsConfiguration.java:117)
at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:563)
at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:589)
at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:543)
at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:519)
at jdk.jdeps/com.sun.tools.jdeps.Main.main(Main.java:49)

@Erel are you think is better to open new thread?
 
Upvote 0

PatrikCavina

Active Member
Licensed User
Longtime User
Reinstalling B4J and openJDK 11 (from the link of erel), I found out that only in this application B4JPackager does not work, in all other applications B4JPackager does not give me errors.
So I think the error is in my application even though it works correctly in the release mode.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
If you’re using any of the following packages (module names in parenthesis)…

  • javax.activation (java.activation)
  • javax.activity, javax.rmi, javax.rmi.CORBA, org.omg.* (java.corba)
  • javax.transaction (java.transaction)
  • javax.xml.bind.* (java.xml.bind)
  • javax.jws, javax.jws.soap, javax.xml.soap, javax.xml.ws.* (java.xml.ws)
  • javax.annotation (java.xml.ws.annotation)
… then you need to replace them with third-party implementations (check this StackOverflow answer for inspiration).
 
Upvote 0
Top