B4J Question (SOLVED) Error trying to run JAR and standalone package - decodeDriverLicense

Johan Schoeman

Expert
Licensed User
Longtime User
Hello all

Attached B4J project refers. It uses bcprov-jdk16-1.43.jar that you can download from the web. When compiling it in B4J it runs fine - no problem whatsoever (release mode and debug mode). When I compile it to a Standalone package and run it with run_debug in the Objects\temp\build folder of the standalone package I get the following error:


B4X:
C:\Users\johans\Documents\B4JApps\decodeDriverLicense\decodeDriverLicense\Objects\temp\build\bin>java.exe @release_java_modules.txt  -m b4j/b4j.example.main
ss = 019b0945000060e9a27a1e475f89af17cb3a5ae86bd91152d22fbca1f462ba8bd39e9341bb26ad82e3ab1b4e68069247b75286edb64fed476c1a444bba7ffeca8ac9ddcf629ac582a865b8eefec682f33de40e68a6fc08265df86ad058376db56e4a9d2a2da285d11f408493fb4706abc346632a156b517c87b58372a3afda8be11dbae4a8f5a3d1881559ce0c69acd026770fd9e75c28c4abd0b2796e70eca894d8546bd8456bdcd9af0aa112f78b56523471b46805ae844a66108ba2f12a28180e5ddded48436239eae212c6193d351201e6a24613d2482ddae552bf7e21729246667a9cd5c730ba4b80736586f5f90894b1017fcea7b299cd6241a266c4b7b28b704de1f0266025358d134686e1cac2ba9af74ea16b9524f4fca20792d2618beec8499dbab596f5a56531f26462c996dad5e1278400a5266c5b5aed2dd3cae135821148bdfd3d564ac127c90d3a125031cb263e63879dfdd10725dc80225a700e5d259a5a1d2340d7bd2d3fecc9b078e1726661e2c51b945b56d762fa3067f2b926dd2707a74e1535abf1a7ee09b0ec40689cd3b3b9995dfdda9b5f33482f1441afa48304a68b24b942464d0334d4b20c17a6f09d5db119257212f7b2d48860e22c64924dc53c03557624a020b175ef47553946ce2e60c3f2ba95865d73b2d440c2fd3eb3c9850447c249c869444dbc103d8197c5556355e6c46455b61aa0b176bcc73290b532726d4339bb35b144fecf5c5d4c5e90aef23fc9c9375ae7206f9ea5a22255365f7e0728e3360cb78562c805a4f9a2b4a674eb5af30b598b98b16227a223505e2e013e426296e8f3d1ff03d6506fa431162438afabbc4e8b9626e8821d6bd264ff9d35a2df90e2be27e0297c162a0a6bbc937f349d31413484b52ca27255b2263abde2793cb946387685de9662777cdf6808a18c3a25759ed4e6ab6410f7881b655421be87e3f3df100062f12ae806059ca3e11248557080a64e4ec6e0a46697cae4c5c5197e3defdc
ss length = 1440
MYSTRING  LENGTH = 258
RSA decryption error : java.io.IOException: problem extracting key: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: RSA, provider: BC, class: org.bouncycastle.jce.provider.JDKKeyFactory$RSA)
LENGTE = 3
char = ?     karak = 9e     MyBase64StringAsBytes(0) = 9e
char = é     karak = e9     MyBase64StringAsBytes(1) = e9
char = e     karak = 65     MyBase64StringAsBytes(2) = 65
main._button1_click (java line: -1)
java.lang.NumberFormatException: For input string: ""
        at java.base/java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.base/java.lang.Integer.parseInt(Unknown Source)
        at b4j/anywheresoftware.b4a.keywords.Bit.ParseInt(Unknown Source)
        at b4j/b4j.example.main._button1_click(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
        at b4j/anywheresoftware.b4a.BA$1.run(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)


C:\Users\johans\Documents\B4JApps\decodeDriverLicense\decodeDriverLicense\Objects\temp\build\bin>pause
Press any key to continue . . .

When trying to run it from "cmd" i.e java -jar decodeDriverLicense.jar I get the following error:

B4X:
C:\Users\johans\Documents\B4JApps\decodeDriverLicense\decodeDriverLicense\Objects>java -jar decodeDriverLicense.jar
Exception in thread "JavaFX Application Thread" Exception in thread "main" java.lang.UnsupportedClassVersionError: b4j/example/main has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplicationWithArgs$2(LauncherImpl.java:352)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:187)
        at java.lang.Thread.run(Unknown Source)
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.NullPointerException
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:383)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
        ... 5 more

Anyone with a solution for this? I am a bit lost with this....
 

Attachments

  • decodeDriverLicense.zip
    5.9 KB · Views: 232
Solution
This works:
B4X:
#AdditionalJar: bcpkix-jdk14-1.48
#AdditionalJar: bcprov-jdk14-1.48
#PackagerProperty: VMArgs = --add-opens b4j/org.bouncycastle.jcajce.provider.asymmetric.rsa=java.base
Will probably work with your version as well.

Johan Schoeman

Expert
Licensed User
Longtime User
No idea about the first error!
Your second error looks like you are using Java 8 to run a Java 11 compiled jar.
I am using Java 11....?

1638627380556.png
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
When trying to run it from "cmd" i.e java -jar decodeDriverLicense.jar I get the following erro
The jdk version of the system (windows) doesn't have to be the jdk of the ide.

Run java --version to get the actual jdk you are using. As agraham stated this could be jdk8
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
The jdk version of the system (windows) doesn't have to be the jdk of the ide.

Run java --version to get the actual jdk you are using. As agraham stated this could be jdk8
Can you please post the exact comand?
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Try java -version
It says:

B4X:
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) Client VM (build 25.271-b09, mixed mode)

What now? Why does B4J reports java 11 and java -version reports 1.8.0_271?
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
It says:

B4X:
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) Client VM (build 25.271-b09, mixed mode)

What now? Why does B4J reports java 11 and java -version reports 1.8.0_271?
I have this configuration:

1638628256398.png
 
Upvote 0

udg

Expert
Licensed User
Longtime User
It's possible that time ago you set the JAVAHOME enviroment variable.
So, having on disk both 1.8 and 1.11 when your run a jar, the JAVAHOME calls the 1.8 version
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
What now? Why does B4J reports java 11 and java -version reports 1.8.0_271?
Java 8 by default is installed with an entry in the Path environment variable pointing to the location of the java executables so typing 'java' runs Java 8. JDK 11 does not do this by intent. You cannot run Java 11 and later from the command line but need some additional steps. Se my post here.

 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Java 8 by default is installed with an entry in the Path environment variable pointing to the location of the java executables so typing 'java' runs Java 8. JDK 11 does not do this by intent. You cannot run Java 11 and later from the command line but need some additional steps. Se my post here.

This works for running the jar - thank you.

Still trying to figure out why the standalone package crashes....
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Run run_debug.bat and post the error message.
Here it is Erel.
B4X:
C:\Users\johans\Documents\B4JApps\decodeDriverLicense\decodeDriverLicense\Objects\temp\build\bin>java.exe @release_java_modules.txt  -m b4j/b4j.example.main
ss = 019b0945000060e9a27a1e475f89af17cb3a5ae86bd91152d22fbca1f462ba8bd39e9341bb26ad82e3ab1b4e68069247b75286edb64fed476c1a444bba7ffeca8ac9ddcf629ac582a865b8eefec682f33de40e68a6fc08265df86ad058376db56e4a9d2a2da285d11f408493fb4706abc346632a156b517c87b58372a3afda8be11dbae4a8f5a3d1881559ce0c69acd026770fd9e75c28c4abd0b2796e70eca894d8546bd8456bdcd9af0aa112f78b56523471b46805ae844a66108ba2f12a28180e5ddded48436239eae212c6193d351201e6a24613d2482ddae552bf7e21729246667a9cd5c730ba4b80736586f5f90894b1017fcea7b299cd6241a266c4b7b28b704de1f0266025358d134686e1cac2ba9af74ea16b9524f4fca20792d2618beec8499dbab596f5a56531f26462c996dad5e1278400a5266c5b5aed2dd3cae135821148bdfd3d564ac127c90d3a125031cb263e63879dfdd10725dc80225a700e5d259a5a1d2340d7bd2d3fecc9b078e1726661e2c51b945b56d762fa3067f2b926dd2707a74e1535abf1a7ee09b0ec40689cd3b3b9995dfdda9b5f33482f1441afa48304a68b24b942464d0334d4b20c17a6f09d5db119257212f7b2d48860e22c64924dc53c03557624a020b175ef47553946ce2e60c3f2ba95865d73b2d440c2fd3eb3c9850447c249c869444dbc103d8197c5556355e6c46455b61aa0b176bcc73290b532726d4339bb35b144fecf5c5d4c5e90aef23fc9c9375ae7206f9ea5a22255365f7e0728e3360cb78562c805a4f9a2b4a674eb5af30b598b98b16227a223505e2e013e426296e8f3d1ff03d6506fa431162438afabbc4e8b9626e8821d6bd264ff9d35a2df90e2be27e0297c162a0a6bbc937f349d31413484b52ca27255b2263abde2793cb946387685de9662777cdf6808a18c3a25759ed4e6ab6410f7881b655421be87e3f3df100062f12ae806059ca3e11248557080a64e4ec6e0a46697cae4c5c5197e3defdc
ss length = 1440
MYSTRING  LENGTH = 258
RSA decryption error : java.io.IOException: problem extracting key: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: RSA, provider: BC, class: org.bouncycastle.jce.provider.JDKKeyFactory$RSA)
LENGTE = 3
char = ?     karak = 9e     MyBase64StringAsBytes(0) = 9e
char = é     karak = e9     MyBase64StringAsBytes(1) = e9
char = e     karak = 65     MyBase64StringAsBytes(2) = 65
main._button1_click (java line: -1)
java.lang.NumberFormatException: For input string: ""
        at java.base/java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.base/java.lang.Integer.parseInt(Unknown Source)
        at b4j/anywheresoftware.b4a.keywords.Bit.ParseInt(Unknown Source)
        at b4j/b4j.example.main._button1_click(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
        at b4j/anywheresoftware.b4a.BA$1.run(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)


C:\Users\johans\Documents\B4JApps\decodeDriverLicense\decodeDriverLicense\Objects\temp\build\bin>pause
Press any key to continue . . .
 
Last edited:
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Try to add this:
B4X:
#PackagerProperty: IncludedModules = jdk.crypto.ec
Does it help?
Same error Erel:
B4X:
RSA decryption error : java.io.IOException: problem extracting key: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: RSA, provider: BC, class: org.bouncycastle.jce.provider.JDKKeyFactory$RSA)
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
This works:
B4X:
#AdditionalJar: bcpkix-jdk14-1.48
#AdditionalJar: bcprov-jdk14-1.48
#PackagerProperty: VMArgs = --add-opens b4j/org.bouncycastle.jcajce.provider.asymmetric.rsa=java.base
Will probably work with your version as well.
Working 100% - thank you Erel!
 
Upvote 0
Top