Java字节码和.NET字节码有什么区别吗?如果是这样,我应该采用该值的十六进制吗?
我想知道Java字节码和.NET字节码有什么区别吗?如果有任何区别,我应该采用 Java 字节码和 .Net 字节码的十六进制值吗?因为,十六进制与语言无关,是通用规范。
问题描述
我们正在用 j2me 和 Java 开发一个移动应用程序。在这里,我使用外部指纹读取器来读取/验证指纹。我们使用一个 Java API 来读取/验证指纹。
我捕获手指模板和原始图像字节。我将原始图像字节转换为十六进制形式并存储在单独的文本文件中。
这里我们使用一个转换工具(用.NET开发)将十六进制形式转换为图像。在该工具的帮助下,我们尝试从该文本文件中获取图像。但我们无法正确获取图像。
.NET 程序员说 Java 字节和 .NET 字节不同。 Java字节范围是-128到127。但是.NET字节范围是0到255。所以有一个问题。
但我的假设是:十六进制独立于 Java 和 Java。 。网。这对两者来说都是共同的。因此,我计划将该字节代码转换为十六进制格式,而不是将字节代码存储在文本文件中。因此,我们的.NET转换工具会自动将此十六进制转换为图像。
我不知道我走的路是否正确?
I would like to know if there any difference between Java byte code and .NET byte code? If there any difference, shall I take hexadecimal values of that Java byte code and .Net byte code. Because, hexadecimal is independent of languages and it is universal specification.
Problem description
We are developing a mobile application in j2me and Java. Here I am using external finger print reader for reading/verifying finger print. We are using one Java api for reading/verifying finger print.
I capture the finger template and raw image bytes. I convert the raw image bytes into hex form and stored in a separate text file.
Here we using a conversion tool (developed in .NET) that converts the hex form into image. With the help of that tool we are trying to get the image from that text file. But we cannot get the image correctly.
The .NET programmer says the Java byte and .NET byte differ. Java byte ranges from -128 to 127. But .NET byte ranges from 0 to 255. So there is a problem.
But my assumption here is: the hex is independent of Java & .net. It is common to both. So, instead of storing byte code in text file, I plan to convert that byte code into hexadecimal format. So,our .NET conversion tool automatically convert this hexadecimal into Image.
I don't know whether I am going on correct path or not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
十六进制只是表示数字的一种方式。
Java 被编译为字节码并由 JVM 执行。
.NET 被编译为字节码并由 CLR 执行。
这两种格式完全不兼容。
Hexadecimal is just a way to represent numbers.
Java is compiled to bytecode and executed by a JVM.
.NET is compiled to bytecode and executed by the CLR.
The two formats are completely incompatible.
好的;请注意,存储为二进制会更容易(并且更有效),但这应该可行
与其担心图像,首先要做的是检查问题出在哪里;有两种明显的情况:
首先将其作为图像加载;只需存储一些已知数据并尝试在另一端读回即可找出其中的哪一个。
对于任何编写良好的十六进制编码来说这不应该是问题。我希望单个 java 字节能够正确写入 00 和 FF 之间的单个十六进制值。
就我个人而言,我怀疑您误解了问题,这使得解决方案很可能偏离目标。如果您想让生活更轻松,请存储为二进制而不是文本;但交换十六进制并不存在固有的问题。如果我必须将原始二进制数据打包到文本文件中,个人我可能会选择base-64而不是十六进制(它会更短),但两者都可以美好的。
正如我上面提到的:首先弄清楚问题是否出在读取字节,而不是将字节处理成图像。我还假设这里的字节是两种环境都可以处理的图像格式,而不是(例如)自定义序列化格式。
OK; note, storing as binary would have been easier (and more efficient), but that should work
Rather than worrying about the image, the first thing to do is check where the problem is; there are two obvious scenarios:
First; figure out which of those it is, simply by storing some known data and attempting to read it back at the other end.
That shouldn't be a problem for any well-written hex-encode. I would expect a single java byte to correctly write a single hex value between 00 and FF.
Personally, I suspect you are misunderstanding the problem, which makes it likely that the solution is off the mark. If you want to make life easier, store as binary rather than text; but there is no inherent problem exchanging hex around. If I had to pack raw binary data into a text file, personally I'd probably go for base-64 rather than hex (it will be shorter), but either is fine.
As I mentioned above: first figure out whether the problem is in reading the bytes, vs processing the bytes into an image. I'm also making the assumption that the bytes here are an image format that both environments can process, and not (for example) a custom serialization format.
是的,Java字节码和.NET的字节码是两个不同的东西,不能互换。至于你问题的第二部分,我不知道你在说什么。
Yes, Java byte code and .NET’s byte code are two different things that are not interchangeable. As to the second part of your question, I have no idea what you are talking about.
是的,它们是不同的,但有些工具可以从一种工具迁移到另一种工具。
在 google 中搜索
java 字节码 IL 比较
。 这个来自同一个 搜索Yes they are different while there are tools that can migrate from one to an other.
Search google fro
java bytecode IL comparison
. This one from same search