Java 如何判断 jar 是在 64 位还是 32 位系统上编译的?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18713591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 10:24:26  来源:igfitidea点击:

How can I tell if a jar was compiled on a 64bit or 32bit system?

java

提问by Zhenya

I have a jar but I don't know if it is a .jarfor a 64bit system or for a 32bit system. How to find that out?

我有一个 jar,但我不知道它是.jar用于 64 位系统还是用于 32 位系统。怎么查出来?

EDIT: My .jarhas native library dependency.

编辑:我.jar有本机库依赖项。

采纳答案by Gyanendra Dwivedi

Java bytecode is java bytecode, it doesn't matter whether it was built with a 32-bit or 64-bit JDK and there is no way to figure this out.

Java字节码就是java字节码,它是用32位还是64位JDK构建的都没有关系,没有办法弄清楚。

I think it does not make any difference to have a jar compiled with 32-bit or 64-bit. It should be machine-independent; unless you have some native library dependency or the java code is directly being compiled to native code.

我认为用 32 位或 64 位编译 jar 没有任何区别。它应该独立于机器;除非您有一些本机库依赖项或 java 代码直接被编译为本机代码。

回答by Bathsheba

A pure jar is not compiled to a particular architecture.

纯 jar 不会编译为特定架构。

A 32 bit JVM will run the jar in 32 bit, likewise a 64 bt JVM will run the jar in 64 bit.

32 位 JVM 将以 32 位运行 jar,同样,64 bt JVM 将以 64 位运行 jar。

Of course, if your jar uses native libraries then the 'bitness' of these will have to match the JVM that you use to run the jar.

当然,如果您的 jar 使用本机库,那么这些库的“位数”必须与您用来运行 jar 的 JVM 相匹配。

回答by Rameez

That's beauty of JVM and platform independence means. There is no value to 32bit or 64bit when it comes to Java, JVM, Jar etc.

这就是 JVM 和平台独立性的美妙之处。对于 Java、JVM、Jar 等,32 位或 64 位没有价值。