在 Windows 64 位上编译 Java jar 并在 RPI 32 位上执行它



搜索堆栈溢出

当我在 Windows 10 64 位计算机上将其作为 jar 文件运行时,以下代码工作正常,但是当我将 jar 文件复制到 RPI 时,它会始终生成错误消息错误。我尝试了从上面的链接使用 JAVAW 的建议,但在 RPI 上找不到该命令。 IOW,无法在 RPI 上正确计算校验和。 关于如何解决此问题的任何建议?

int messageBody[] = new int[(messageLen / 2) - 2];
checkSum = 0;
            for (int charPtr = 2; charPtr < messageLen; ) {
                firstChar = theMessage.charAt(charPtr++);
                secondChar = theMessage.charAt(charPtr++);
                theValue = ((firstChar >= 'A' ? (firstChar - 'A') + 10 : (firstChar - '0')) << 4)
                        | (secondChar >= 'A' ? (secondChar - 'A') + 10 : (secondChar - '0'));
                if (messagePtr < messageBody.length) {
                    checkSum += theValue;
                    messageBody[messagePtr++] = theValue;
                    continue;
                }
                // Compute checksum
                checkSum = (-checkSum & 0xff);
                if (checkSum != theValue) {
                    System.err.println(System.lineSeparator() + "Check sum on received UPB packet failed -- should be " + checkSum + " but received as " + theValue);
                    System.err.println(System.lineSeparator() +"   BAD MESSAGE[" + theMessage + "], " + theMessage.length() + " bytes");
                    return;
                }
            }

我唯一想到的是不同的字符串编码......

用 32/64 位编写的 java 原生代码是不可移植的,我们需要在目标环境中重新编译。

参考网址:http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#64bit_native_porting

嗨,格罗吉和鲍勃·感谢您的输入。

相关内容

最新更新