I'm developing a program to measure weight by connecting a PC with an electronic scale.
I'm developing a language with Kotlin, and I'm trying to refer to Java's library, JSSC.
but I don't know what to do because I get a reference error every time.
The development tool is IntelliJ from JetBrain.
import jssc.SerialPortList
object Main {
@JvmStatic
fun main(args: Array<String>) {
val portNames = SerialPortList.getPortNames()
for (i in portNames.indices) {
println(portNames[i])
}
}
}
The top one is a kortlin and the bottom one is a java. I used the translator of the development tool.
import jssc.SerialPortList;
public class Main {
public static void main(String[] args) {
String[] portNames = SerialPortList.getPortNames();
for(int i = 0; i < portNames.length; i++){
System.out.println(portNames[i]);
}
}
}
Java executed, but Kotlin was unable to compile due to errors such as
Unresolved reference:jssc
Unresolved reference: SerialPortList
I'm not sure how to avoid these reference errors, so I'm asking for advice.
Please give me a good answer.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…