java 调用dll库 枚举参数传递问题
dll中参数是枚举,java怎么传递枚举参数现在这是写的java调用dll1.枚举publicclassTPROTOCALTYPE{publicenumtProtocal...
dll 中参数是枚举, java怎么传递枚举参数
现在这是写的java调用dll
1.枚举
public class TPROTOCALTYPE {
public enum tProtocalType {
UART_XDHT, UART_21, UART_30, UART_LKD, UART_40
}
}
2.调用
public class ZHJOpen {
static {
System.loadLibrary("ZhjDll");
System.out.println("success!");
}
public native boolean OpenSerialPort(int nPortNum, TPROTOCALTYPE.tProtocalType t, int b);
public boolean OpenSerialPortT(int uPort, TPROTOCALTYPE.tProtocalType t, int dwB) {
return this.OpenSerialPort(uPort, t, dwB);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
ZHJOpen zhj = new ZHJOpen();
boolean bol = zhj.OpenSerialPortT(4, TPROTOCALTYPE.tProtocalType.UART_40, 115200);
if (bol) {
System.out.println("true");
} else {
System.out.println("false");
}
}
}
出现的错误
Exception in thread "main" java.lang.UnsatisfiedLinkError: ZHJOpen.OpenSerialPort(ILTPROTOCALTYPE$tProtocalType;I)Z
at ZHJOpen.OpenSerialPort(Native Method)
at ZHJOpen.OpenSerialPortT(ZHJOpen.java:10)
at ZHJOpen.main(ZHJOpen.java:21) 展开
现在这是写的java调用dll
1.枚举
public class TPROTOCALTYPE {
public enum tProtocalType {
UART_XDHT, UART_21, UART_30, UART_LKD, UART_40
}
}
2.调用
public class ZHJOpen {
static {
System.loadLibrary("ZhjDll");
System.out.println("success!");
}
public native boolean OpenSerialPort(int nPortNum, TPROTOCALTYPE.tProtocalType t, int b);
public boolean OpenSerialPortT(int uPort, TPROTOCALTYPE.tProtocalType t, int dwB) {
return this.OpenSerialPort(uPort, t, dwB);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
ZHJOpen zhj = new ZHJOpen();
boolean bol = zhj.OpenSerialPortT(4, TPROTOCALTYPE.tProtocalType.UART_40, 115200);
if (bol) {
System.out.println("true");
} else {
System.out.println("false");
}
}
}
出现的错误
Exception in thread "main" java.lang.UnsatisfiedLinkError: ZHJOpen.OpenSerialPort(ILTPROTOCALTYPE$tProtocalType;I)Z
at ZHJOpen.OpenSerialPort(Native Method)
at ZHJOpen.OpenSerialPortT(ZHJOpen.java:10)
at ZHJOpen.main(ZHJOpen.java:21) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |