Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

classpath

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.

like image 878
Pemassi Avatar asked Sep 11 '19 05:09

Pemassi


1 Answers

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.

like image 73
Ivan Krizsan Avatar answered Nov 06 '22 13:11

Ivan Krizsan