B4J Question Still problems with COM ports

Didier9

Well-Known Member
Licensed User
Longtime User
I made the mistake of upgrading from the older Oracle java setup I had by installing jdk19 + jfx as recommended on the setup page and now opening the COM port crashes the machine,

B4X:
WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
Mainform.Height: 620
Selected WIFI232-T
Opening port COM10 at 115200
Sending: +++
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffe516050d0, pid=18748, tid=20372
#
# JRE version: OpenJDK Runtime Environment (19.0.2+7) (build 19.0.2+7-44)
# Java VM: OpenJDK 64-Bit Server VM (19.0.2+7-44, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Problematic frame:
# V  [jvm.dll+0x150d0]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\xxxxxxxx\DOCUME~1\!Sync\Sync\B4JPRO~1\RADIOC~1\dev\Objects\hs_err_pid18748.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

The debug file is attached.
Any help appreciated!
 

stevel05

Expert
Licensed User
Longtime User
Which version of java have you upgraded from?

It looks like the module com.sun.javafx.embed.swing.oldimpl may have been removed or hidden from newer versions of Java.

It's not something I've used, so will need investigation. Someone may be able to help directly but if not, Can you show the code you are using to open the com port?
 
Last edited:
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Which version of java have you upgraded from?

It looks like the module com.sun.javafx.embed.swing.oldimpl may have been removed or hidden from newer versions of Java.

It's not something I've used, so will need investigation. Someone may be able to help directly but if not, Can you show the code you are using to open the com port?
This computer was running with jdk-11.0.1. This is my main development machine. Recently I have not been working on serial com software, the last time may have been 2-3 months ago. I have been working on non-COM software and had no problem. But I had to update one of those COM applications and I started getting this error. I did not intentionally make changes to this machine with regards to Java in the meantime, but this being a development machine, I regularly update other tools so I am not sure what happened.
The problem does not go away if I revert to jdk-11.0.1
At the moment, even apps that I have not touched (no rebuild, just running the old used-to-be working jar file) no longer work, in the IDE or the jar file.
This is a bit scary as my business depends on it. I have my older backup machine still runnng the jar files, I am scared to run the IDE on that one because I ABSOLUTELY need this software running and I can't afford to break anything.

I know that in the past I had this issue consistently with the OpenJDK but not with the Oracle version, but I have not been able to get the jdk+jfx from the Oracle website and I am not sure how to go about rebuilding that.

Sub OpenCOMPort:
Sub OpenCOMPort As Boolean
    Try
        sp.Open( COMPort )
    Catch
        Log( "Cannot open " & COMPort & CRLF & LastException )
        Return False
    End Try
    Try
        ' COM port always running 8,N,1, parity check done in software
        sp.SetParams( BaudRate, 8, 1, 0 )
    Catch
        Log( "Cannot set params" & CRLF & LastException)
        Return False
    End Try
    Try
        Astream.Initialize( sp.GetInputStream, sp.GetOutputStream, "AStream" )
    Catch
        Log( "Cannot open Astream" )
        Return False
    End Try
    PortOpen = True
    Return True
End Sub ' OpenCOMPort
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Have you updated to the latest jSerial library? Post in thread '(Solved) Error building Standalone Package with jSerial library v1.40' https://www.b4x.com/android/forum/t...ith-jserial-library-v1-40.165988/post-1017771

The warning can be safely ignored
Post in thread 'WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing' https://www.b4x.com/android/forum/t...ldimpl-not-in-javafx-swing.157518/post-966902

I remember way back trying to update the jssc library when running OpenJDK and I did get it working one time, only to have it break and spend more time at the next update so I got tired of this. I never had to do that with Oracle java, which is why I stuck with it.

I remember having this issue with OpenJDK forever and I can't imagine why it has not been fixed. COM port was the first peripheral added to MS-DOS (with the long gone printer port). It's not new.

The link you attached refers to the B4J packager. I do not have it installed. I did try it a while back but it only worked with OpenJDK so no serial port for me. Will instaling it as described in the post you linked fix the issue with the IDE as well? I am leery of doing anything other than the absolute minimum I need to fix this issue. I do not need the B4J Packager at this time, but if it's the way to fix the IDE, I will do that.

I am sorry, this is saturday morning and I have a deadline and I did not sleep well because of that. I do not need to deliver an executable or jar file, I just need to be able to run the software on this PC so I can test my product (embedded system). Running in the IDE would be fine if it works.
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
I see I need to add this to the top of my project file:

B4X:
#CustomBuildAction: After Packager, %WINDIR%\System32\robocopy.exe, ..\ temp\build\bin\ jssc.dll

but will this work even if I do not run the packager?

I did that and I did copy the jssc file to my project folder (same folder as the main b4j project file and the problem is still there (running in debug mode)
I tried to copy the file manually to the temp\build\bin folder and it is still broken.
 
Last edited:
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
I have another laptop where B4J is running the COM port without crashing (jdk-14.0.1, not sure if it's Oracle or OpenJDK), so I should be ok for now. Sorry about the freak-out. I still would like the issue fixed eventually of course but I should be OK for this deadline.

One more piece of data: I copied the entire jdk-14.0.1 folder from the working machine to this one and reset the path in B4J and the issue is not fixed.
 
Last edited:
Upvote 0

Chris2

Active Member
Licensed User
Longtime User
I hope you slept better last night.

I have an old app that uses jSerial. I've just tried it with jdk 19.0.2 downloaded from https://www.b4x.com/b4j.html and the latest jSerial from https://www.b4x.com/android/forum/threads/jserial-library.34762/#content. It connects to the serial port without any problems.

I remember having this issue with OpenJDK forever and I can't imagine why it has not been fixed.
Based on my statement above, and the fact that I've only ever used OpenJDK and have always had comms port conections in this app, I don't think your issue is down to a problem in OpenJDK.

If you're getting this error running in debug within the IDE then you can ignore all the packager stuff for now.
My first suggestion would be to make sure that you have all four of the files related to the jSerial library in your Additional Libraries folder (the latest versions from the jSerial.zip file from here):
jSerial.jar
jSerial.xml
jssc.jar
slf4j-jdk14-1.7.35.jar.


If that doesn't help, I'd suggest creating a small app that has just your serial connection code and trying that. If it won't run for you, upload it here and I'll try it on my machine.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
I hope you slept better last night.

I have an old app that uses jSerial. I've just tried it with jdk 19.0.2 downloaded from https://www.b4x.com/b4j.html and the latest jSerial from https://www.b4x.com/android/forum/threads/jserial-library.34762/#content. It connects to the serial port without any problems.


Based on my statement above, and the fact that I've only ever used OpenJDK and have always had comms port conections in this app, I don't think your issue is down to a problem in OpenJDK.

If you're getting this error running in debug within the IDE then you can ignore all the packager stuff for now.
My first suggestion would be to make sure that you have all four of the files related to the jSerial library in your Additional Libraries folder (the latest versions from the jSerial.zip file from here):
jSerial.jar
jSerial.xml
jssc.jar
slf4j-jdk14-1.7.35.jar.


If that doesn't help, I'd suggest creating a small app that has just your serial connection code and trying that. If it won't run for you, upload it here and I'll try it on my machine.
That did it. When I copied the files, it said only 3 were already there, so I must have missed one. Not sure why it was not there since this machine was working before, but I'll take success anyday. Questions are optional :)

Thank you so much!

Just for completeness, I am running jdk-14-0.1 at the moment.
 
Last edited:
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
The recommended Java for B4J is OpenJDK 19 + OpenJFX
This is maybe relevant?

Thank you Manfred. Previous attempts at OpenJDK 19 were not successful, but now that it's working and I know I have at least one spare working machine I will try that :)
I would like to use the built-in packager rather than the external Launch4J utility I have been using (nothing wrong with it other than being yet another tool to keep track of)
 
Upvote 0

Chris2

Active Member
Licensed User
Longtime User
When I copied the files, it said only 3 were already there, so I must have missed one.
I would guess it was the jssc.jar that was missing from the libraries folder, but I might be wrong. Anyway, I'm glad you got it sorted!

I would like to use the built-in packager
This is where you'll need to make sure that the jssc.dll from here gets copied to the \Build\Bin\ folder.
So, as you stated in post #6 copy it to your project folder and add
B4X:
#CustomBuildAction: After Packager, %WINDIR%\System32\robocopy.exe, ..\ temp\build\bin\ jssc.dll
[don't get confused between the jssc.jar that is the library, and the jssc.dll that needs to be incuded in your packaged app]
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
I have installed OpenJDK 19 and jssc is till working but there is still another issue that everything works in the IDE but the result.jar file does not run. . I will open a separate post for that.
 
Upvote 0
Top