B4J Question smartcardio class not found Exception

Hengki

Member
Licensed User
Longtime User
Hi all,
I want to ask and ask for advice, I'm trying to make a small application to get a list of smartcard readers, after I try to compile (debug and release) it works, the list of smartcard readers appears, but if I build a standalone package form the application only appears briefly then disappears , when I checked there was an error ( java.lang.ClassNotFoundException: javax$smartcardio$TerminalFactory)
My question is, are there still deficiencies in making packages and what should be added, please advise.
thank you

b4j script:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    Private Button1 As B4XView
    Private TerminalFactory, tf As JavaObject
    Private lst As List
    Private ComboBox1 As ComboBox
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    tf=TerminalFactory.InitializeStatic("javax.smartcardio.TerminalFactory")
End Sub

 

public Sub getReaderList As Map
    Dim mp As Map
    mp.Initialize
    tf= TerminalFactory.RunMethod("getInstance",Array("PC/SC",Null))
    Try
        lst= tf.RunMethodJO("terminals",Null).RunMethod("list",Null)
        If lst.Size >0 Then
            For i =0 To lst.Size -1
                mp.Put(lst.Get(i),i)
            Next
            mp.Put("count",mp.Size)
            mp.Put("errcode",0)
            mp.Put("errdesc","success")
        End If
        Return IIf(mp.Size>0 ,mp,Null)
    Catch
        mp.Put("count",0)
        mp.Put("errcode",-1)
        mp.Put("errdesc","no readers avaible")
        Log(LastException)
    End Try
    Return mp
End Sub
 
Sub Button1_Click
    Dim mp As Map = getReaderList
    If mp.Size >0 Then
        ComboBox1.Items.Add( mp.GetKeyAt(0))
    End If
End Sub


Smartcard Error :
main._appstart (java line: -1)
java.lang.ClassNotFoundException: javax$smartcardio$TerminalFactory
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Unknown Source)
        at b4j/anywheresoftware.b4j.object.JavaObject.getCorrectClassName(Unknown Source)
        at b4j/anywheresoftware.b4j.object.JavaObject.InitializeStatic(Unknown Source)
        at b4j/b4j.example.main._appstart(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.raiseEvent(Unknown Source)
        at b4j/b4j.example.main.start(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)
        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)
 

Attachments

  • smartcardio.rar
    400.9 KB · Views: 130

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
the packager usually nees some extra configuration to recognize some jars, classes and modules

look here:

there are examples for webview, poi, ssl. so on and so forth.
Try experimenting with exports and opens directives.

is that or you are indeed not linking the libraries look for the directve: #merge libraries
 
Upvote 0

Hengki

Member
Licensed User
Longtime User
the packager usually nees some extra configuration to recognize some jars, classes and modules

look here:

there are examples for webview, poi, ssl. so on and so forth.
Try experimenting with exports and opens directives.

is that or you are indeed not linking the libraries look for the directve: #merge libraries
I have tried using b4j package 11 , but it still doesn't work, the error is still the same
 
Upvote 0
Top