B4J Question [SOLVED] Very strange issue on B4J

max123

Well-Known Member
Licensed User
Longtime User
Hi all programmers,

I've a very strange issue on B4J 10.00.

I've developed some graphic controls libraries used on my apps for a long time.

These libraries are developed directly in B4J and compiled as libraries.

Now I've some projects that works as expected, just by select the libraries in the Library Tab.
On another project I do the same, but when I compile B4J log show me this error message:
main._process_globals (java line: 1548)
java.lang.UnsupportedClassVersionError: b4j/example/classled 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(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at b4j.example.main._process_globals(main.java:1548)
at b4j.example.main.initializeProcessGlobals(main.java:1463)
at b4j.example.main.start(main.java:34)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
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:185)
at java.lang.Thread.run(Thread.java:750)
Libraries are compiled with B4J itself, so I don't know because java version is not the same. On preferences I've set JDK 11.

If I import the library classes inside the projects they compile without errors.

Recently i dismissed the AdditionalLibraries folder by just renaming it AdditionalLibrariesBackup and created a new one in Documents containing libraries for all platforms:
C:\Users\Massimo\Documents\B4X-AdditionalLibraries
On this folder I've B4A, B4J, B4i, B4R, B4X and B4XlibXMLFiles sub-folders respectively containing additional libraries for any platform.

Please can someone explain me because this happen ? I missed something ?
I have to release in the forum some libraries, but before it happen I have to solve this problem.

Many thanks
 
Last edited:

aeric

Expert
Licensed User
Longtime User
Maybe you should list down all the libraries you are using in your project.

 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
From the error message

b4j/example/classled was compiled with java 9 ( version 53 ) you are using java 8 ( version 52.0 ).
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
1706035512421.png

Many thanks for replies,

I cannot list all libraries I use in my projects, they are my personal libraries I developed and next I have to release on this forum.
As I said these are just classes I compiled as libraries, importing the class as module works, importing from library tab works only on certains projects an do not in others and returns this error I posted.

I don't have Java9 on my system.

I have both Java11 and Java8, but the JRE is Java8.
This worked well until now, even works with some other current projects.
The first Java11 SDK in the list is what B4J use to compile.

The very strange thing is that some works and some return this error.

All projects are normal projects (eg. no B4XPages).

But I do not know because some projects runs well just selecting the library in the library tab and others do not.

Always worked. This problem seem started when I created a B4X library common folder in my Documents and setup this accordly to the IDE paths.
 
Last edited:
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
just to get a complete picture, are you trying to run an app compiled with java 11 on the java 8 jre?
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
@Daestrum No. I don't know how I can do it, from command prompt by specify the JDK path manually instead of default JRE ?

But this works on some projects. And always worked until now. I cannot launch jar files from system, but always worked from B4J IDE.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Maybe I found a mistake... Not sure if this is the problem but...

I have the ShareModules folder inside B4J installation, and inside here there are the classes that won't compile... so they are doubled... in SharedModules folder and in /Documents/B4X-AdditionalLibraries (these are the one I mantain an continue to uptate)

The classes in SharedModules probably are old, and I've put here to use as shared modules, but never used.

Probably by having the AdditionalLibraries folder inside B4J installation have precedence (when compile) on it and SharedModules classes are not used at all.
Because I renamed AddictionalLibrary folder (just as bakups) and moved additional libraries folder in Documents, may the compiler now compiles with the SharedModules classes that are old classes ?

1706039054775.png
 
Last edited:
Upvote 0

zed

Active Member
Licensed User
I think to be compiled the library must be in an additional library.
The shared module is apparently only for simple code
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
You are absolutely right @zed, now I confused myself....
in shared modules there are only the library code .bas, that has nothing to do with .jar and .xml library files to load a library.

When I compile one library B4J put the .jar and .xml files in the right place, inside Documents addictional libraries, inside B4J sub-folder.
I compile it without problems, but after this some projects can use it, some others do not. Just returns the error I posted on first post.

In projects where I receive error if I create a new class with the same library name and put here the library code, all compile without errors.

Very strange thing...

1706049907363.png
 
Last edited:
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I seem to recall (from years ago) the IDE was released to work with java 9 (jigsaw - modules) as I remember jfx9 included in some library file names. Maybe some of your old libraries were compiled with that version. - just guessing -
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
But sorry,

maybe I confused you by saying that in SharedModules I have the modules of my old libraries.
As noted, this has nothing to do with the fact that libraries imported from the Library Tab do not work when compiling a project.

Right now I have the project of one of these libraries, the updated project (main + class module), I compile it as a library, but then when I select it from library tab on some projects it compiles, on others it doesn't.

If I import in the project the same class it compile without this error but from library tab it do not.

What I miss ?
Why does this happen?

The library is updated, it is not old.... I compiled as library just now, even changing the library version and this match the one on library tab when I refresh it.
The library have some included project examples, they work just to import the library from library tab, but on certain other projects this do not happen.
 
Last edited:
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Ok, finally the problem was solved o_O

I discovered this line in the project that do not compile....
#JavaCompilerPath: 8, C:\java\jdk1.8.0_351\bin\javac.exe
so it compiles with Java8 instead of Java11....

This is a project I mantain from a long time and continue to improve it. I do not remember because I had to add this line,
probably to test the compiled jar file to an old Linux machine or a Raspberry with Java8.

I will continue this thread if I encounter the same problem after some tests. If no I put SOLVED in the thread title.

Sorry for inconvenience and thanks all for your appreciated help.
B4X TheBest
 
Last edited:
Upvote 0
Top