javax.smartcardio.* is not found on Open JDK 11(Redhat)

天涯浪子 提交于 2020-02-02 12:39:03

问题


I am using Redhat's OpenJDK 11 to communicate with a smart card on the Windows. But I have a problem with compiling. It said cannot find javax.smartcardio library.

Enviornment : Redhat OpenJDK 11, Intellij, Kotlin, Gradle

> Task :compileKotlin
e: ~\util\SmartCard.kt: (7, 14): Unresolved reference: smartcardio
e: ~\util\SmartCard.kt: (13, 25): Unresolved reference: CardTerminal
e: ~\util\SmartCard.kt: (13, 41): Unresolved reference: TerminalFactory
e: ~\util\SmartCard.kt: (19, 51): Unresolved reference: CardTerminal
e: ~\util\SmartCard.kt: (25, 43): Unresolved reference: CardTerminal
e: ~\util\SmartCard.kt: (35, 23): Unresolved reference: Card
e: ~\util\SmartCard.kt: (36, 30): Unresolved reference: CardChannel
e: ~\util\SmartCard.kt: (44, 52): Unresolved reference: CardException
e: ~\util\SmartCard.kt: (51, 19): Unresolved reference: CardException
e: ~\util\SmartCard.kt: (54, 27): Unresolved reference: CommandAPDU

Also, I already looked classpath, and there is 'java.smartcardio' I attached a screenshot below.

What should I do?

ADD----------------

Wired thing is in Java code, it is working on same project. I think there is a problem with Kotllin environment settings.


回答1:


I think you need to include the java.smartcard module into the module in which the code that uses the unresolved classes you list is located. I created a small Kotlin project named kotlinsmartcard with the following code in the se.ivankrizsan package:

fun main() {
    val theCardTerminal: CardTerminal;
    println("Hello World!")
}

In the source root, that is not in any package, I have a file named module-info.java with the following contents:

module kotlinsmartcard {
    requires kotlin.stdlib;
    requires java.smartcardio;
}

I am able to run the above program using JDK 11.0.3-zulu (used this since I do not have the RedHat JDK at hand). This way my entire kotlinsmartcard project is one single module, in order to minimize the exposure to the Java module system, but I still need to have the "requires java.smartcardio" in order to not have an error at the variable declaration in the code.




回答2:


Here is an alternative way. I just give up using JDK's SmartCard classes since it was hard to use JDK one on JDK 11 version. Instead of it, I used a library from Github.

Here it is.

https://github.com/intarsys/smartcard-io



来源:https://stackoverflow.com/questions/57882888/javax-smartcardio-is-not-found-on-open-jdk-11redhat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!