简体   繁体   English

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

[英]Compiling Java jar on windows 64 bit and executing it on RPI 32 bit

Searched StackOverflow 搜索的StackOverflow

The following code works fine when I run it as a jar file on Windows 10 64 bit machine but when I copy the jar file over to a RPI, it consistently generates the Bad message error. 当我在Windows 10 64位计算机上将其作为jar文件运行时,以下代码可以正常工作,但是当我将jar文件复制到RPI时,它将始终生成Bad Message错误。 I tried the suggestion to use JAVAW from the above link but the command cannot be found on the RPI. 我尝试了从上面的链接使用JAVAW的建议,但是在RPI上找不到该命令。 IOW, the checksum can't be correctly calculated on the RPI. IOW,无法在RPI上正确计算校验和。 Any suggestions on how to fix this issue? 有关如何解决此问题的任何建议?

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;
                }
            }

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

The native code in java which is written in 32/64 bit is not portable and we need to recompile in target environment. 用32/64位编写的Java本机代码不可移植,我们需要在目标环境中重新编译。

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

Hi Grogi & Bob S, Thanks for the input. 嗨,Grogi和Bob S,谢谢您的输入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM