B4J Question jSerial crash without error

mauro vicamini

Active Member
Licensed User
Longtime User
Hi evreyone,
I've developped and application that comunicate with some devices through USB with virtual COM using jSerial library
I've a strange problem: when I try to open the COM the application close without errors.
Here the piece of code involved:
B4X:
Dim exc As ExceptionEx
    Try
        'objSerial object previously declared as Serial and inizialized by objSerial.Initialize("objSerial")
        Log("CONNECT ON PORT "  & mPort)
        objSerial.Open(mPort)
        Log("OPENED PORT " & mPort)
        objSerial.SetParams(19200,8,1,0)
        Log("PARAMETERS SET")
        objAsyncStream.Initialize(objSerial.GetInputStream,objSerial.GetOutputStream,"objAsyncStream")
        Log("ASYNCSTREAM OPENED")
        If SubExists(objCaller,mEventName & "_Connected") Then
            CallSubDelayed(objCaller,mEventName & "_Connected")
        End If
    Catch
        Log("ERROR: " & LastException.Message)
        exc = LastException
        exc.Throw
    End Try
    Log("END CONNECTION PROCEDURE")

I use RedirectOutput function to redirect the log trace on file and on the log file I see as the last trace "OPENED PORT " with the correct COM name and nothing more. No trace of an eventual error catched by the Try/Catch. I've also a log trace in the Application_Error event, but no sign of it on the log file.
The strange thing is that in the IDE it works (on windows 10) , but the executable application has problem on another Windows 10.
I use this Java version for the executable

java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

The same I've in the IDE.

Any hint is aprecieted.

Thanks
 

bdunkleysmith

Active Member
Licensed User
Longtime User
If it is the same problem, this post https://www.b4x.com/android/forum/threads/b4jpackager11-created-exe-cannot-be-run.117523/post-735743 is the most recent describing the problem and points to this post https://www.b4x.com/android/forum/threads/jserial-library.34762/post-735742 which explains how to deal with jssc.dll in order to solve it correctly rather than some of the other fixes which were problematic.

Incidentally from my experience, I can recommend moving to OpenJDK 11 and using the inbuilt packager in B4J v8.30 described here https://www.b4x.com/android/forum/t...-way-to-distribute-standalone-ui-apps.117880/, including automatic inclusion of jssc.dll as per point 5. in that post.
 
Last edited:
Upvote 0

mauro vicamini

Active Member
Licensed User
Longtime User
Worth testing without the try catch block and without the log redirection. It is a lower level error and it might not be redirected.
But how can I see the error and the log trace if I don't redirect the output on a file? It's a UI application, not a console application.
 
Upvote 0

mauro vicamini

Active Member
Licensed User
Longtime User
Run it from the command line with java -jar <your jar>
Strange thing.... I've launched the application like Erel said and all the application works perfectly, but if I launch it from the exe all the application works but crash when I do open on the com port.... I've also copied the jssc dll in the runtime/bin folder but no luck...
What could it be?
 
Upvote 0

mauro vicamini

Active Member
Licensed User
Longtime User
I need to run it by executable. If it could be of any help i attach my .iss file of innosetup
 

Attachments

  • ETLAB.txt
    27.9 KB · Views: 177
Upvote 0

mauro vicamini

Active Member
Licensed User
Longtime User
Another update on the situation: on Wndows7 64bit the same executable application works perfecly. The problem is only on Windows 10 it seems.
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
I feel your pain and unfortunately I don't think I've the skills/knowledge to know the underlying cause.

However can you let us know how you create your "executable"? I presume you're still using Java 8 and the "old" B4JPackager. If so I'd be heading down the path of migrating to OpenJDK 11 and B4J v8.30 so you can use the inbuilt packager as per my post #2.
 
Upvote 0

mauro vicamini

Active Member
Licensed User
Longtime User
I feel your pain and unfortunately I don't think I've the skills/knowledge to know the underlying cause.

However can you let us know how you create your "executable"? I presume you're still using Java 8 and the "old" B4JPackager. If so I'd be heading down the path of migrating to OpenJDK 11 and B4J v8.30 so you can use the inbuilt packager as per my post #2.
Hi bdunkleysmith,
thank for your answer, but if I launch the application with java -jar it works perfectly, why could it be a java version problem for the executable?
Another consideration why I a little bit sceptic in migrating to OpenJDK 11 is that it's only for 64bit and I need to be compatible with 32bit SO.
 
Upvote 0

mauro vicamini

Active Member
Licensed User
Longtime User
I've tried to like bdunkleysmith said and, like I've imagined, also the executabale generated by the packager of B4J 8.30 win OpenJDK11 make the same error.
But I've a new element: I've run the application with the debug.bat and it has trace an error in which there is a reference to log.file like a dump. I attach it.
I hope could it be usefull.
 

Attachments

  • hs_err_pid27180.txt
    85.3 KB · Views: 189
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
I am not skilled enough to interpret the cause of the error from the dump file.

But in this post https://www.b4x.com/android/forum/t...-port-not-found-exception.107652/#post-673144 last year you asked for assistance with similar code.

So did you get your code running successfully back then and this problem has only now surfaced or did you never get the application working?

I tried to create a small project based on code from that earlier post, but that appears to be a non-UI app which can't be packaged and so I presume your new app is a UI app.

Others may be able to help based on your dump file, but if you can't (or don't want to) publish your project so we can look at it in detail, perhaps you could create a simple project containing just the opening of the serial port using your method to demonstrate the problem which the community can examine for you.
 
Upvote 0

mauro vicamini

Active Member
Licensed User
Longtime User
Thanks to everyone,
I've solved: I've update jSerial to 1.31, then rebuild the package with the new packager with OpenJDK11 and than copied the jscc.dll into the build/bin folder. At last I've rebuild the setup file with innosetup. Now it works, but it works only on 64bit platforms. So I will be compelled to have 2 separate setups: one for 64bit(OpenJDK11) and one for 32bit(Java 8, but it is also comapatible with 64bit platform not Windows 10).
One question: jSerial 1.31 works also with Java 8?
 
Upvote 0
Top