Android Question [Solved]How do I import the package of Java code?

Theera

Expert
Licensed User
Longtime User
Refer to myCode which is attached. After I have learn using javaobject with Java Code,so I can create the code. Due to I still not understand about
import javax.smartcardio.*;
it has error occured. I think jnasmartcardio.jar concern about the package of Java code
 

Attachments

  • TestThaiIDSmartCardReader.zip
    20.1 KB · Views: 49
  • jnasmartcardio-0.2.7.jar
    42.1 KB · Views: 43
  • jnasmartcardio-0.2.7-sources.jar
    21.1 KB · Views: 42
Solution
I couldnt get it to work with in-line java, seems like java.smartcardio only exports javax.smartcardio to java.base

using javaobject it does work (I think under the hood it sets accessible true)

B4X:
    Dim j As JavaObject
    Dim factory As JavaObject
    j.InitializeStatic("javax.smartcardio.TerminalFactory")
    factory = j.RunMethod("getDefault",Null)
    Dim terminals As List = factory.RunMethodJO("terminals",Null).RunMethod("list",Null)
    Log(j)
    Log(factory)
    Log(terminals)

MicroDrie

Well-Known Member
Licensed User
Longtime User
Theera did you load the jnasmartcardio-0.2.7.jar file into the additional directory? Additional Libraries, the (optional) folder where libraries will be searched for, in addition to the internal libraries folder. You can find this via Tools.

Update: I look into the jar and see that it want to download the javax.smartcardio.CardTerminal, javax.smartcardio.CardTerminals, javax.smartcardio.TerminalFactory, and jnasmartcardio.Smartcardio libraries. You need to make a wrapper to let it work.
 
Last edited:
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I couldnt get it to work with in-line java, seems like java.smartcardio only exports javax.smartcardio to java.base

using javaobject it does work (I think under the hood it sets accessible true)

B4X:
    Dim j As JavaObject
    Dim factory As JavaObject
    j.InitializeStatic("javax.smartcardio.TerminalFactory")
    factory = j.RunMethod("getDefault",Null)
    Dim terminals As List = factory.RunMethodJO("terminals",Null).RunMethod("list",Null)
    Log(j)
    Log(factory)
    Log(terminals)
 
Upvote 0
Solution

Theera

Expert
Licensed User
Longtime User
[QUOTE="Daestrum, post: 1013721, member: 52836

B4X:
    Dim j As JavaObject
    Dim factory As JavaObject
    j.InitializeStatic("javax.smartcardio.TerminalFactory")
    factory = j.RunMethod("getDefault",Null)
    Dim terminals As List = factory.RunMethodJO("terminals",Null).RunMethod("list",Null)
    Log(j)
    Log(factory)
    Log(terminals)
[/QUOTE]
Where are getDefault and terminals come from? Please help me explain. There are not java sourcecode, are them? And the
package javax.smartcardio.TerminalFactory is from? (I know only "javax.smartcardio.*)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
Where are getDefault and terminals come from? Please help me explain. There are not java sourcecode, are them? And the
package javax.smartcardio.TerminalFactory is from? (I know only "javax.smartcardio.*)

if you look at the source code jar you will see that the standard java classes (like terminals) are extended. That is why the example from post 3 works. In short: you don't need a wrapper but you can implement your program using the given Java object method from post 3.

In short: you don't need a wrapper but you can implement your program using the given Java object method from post 3.
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
If I understand, see the class and the example.
The documentation can be found in the file jnasmartcardio-0.2.7-sources.jar after you unzip it after you change the extension from jar to zip.
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
Here is the zipped jnasmartcardio-0.2.7-sources Doclet explanation of the Java routines.
 

Attachments

  • Doclet.zip
    101.2 KB · Views: 42
Upvote 0

Theera

Expert
Licensed User
Longtime User
Thank you all of you.
 
Upvote 0
Top