简体   繁体   English

Linux和Windows java编译器是否生成相同或不同的类文件?

[英]Do Linux and Windows java compilers produce the same or different class files?

We have Java compilation both on Linux and Windows by the same version 1.6.0_25. 我们在Linux和Windows上使用相同版本的1.6.0_25进行Java编译。

For some reason the resulted class files are different. 由于某种原因,结果类文件是不同的。 Is it correct? 这是对的吗?

The java compiler is not deterministic and may not generate the same .class if compiled on the same platform mulitple times or compiled on different platforms. java编译器不具有确定性,如果在同一平台上编译多次或在不同平台上编译,则可能不会生成相同的.class。 I am trying to figure out the internals of java compiler to see why it is not deterministic. 我试图找出java编译器的内部,看看为什么它不是确定性的。

Searching it further gives more insight while learning about cross compilation option in javac : 在学习javac中的交叉编译选项时,进一步搜索可以提供更多洞察力:

Cross-Compilation Options 交叉编译选项

By default, classes are compiled against the bootstrap and extension classes of the platform that javac shipped with . 默认情况下,类是根据javac附带的平台的引导程序和扩展类编译的 But javac also supports cross-compiling, where classes are compiled against a bootstrap and extension classes of a different Java platform implementation. 但javac还支持交叉编译,其中类是针对不同Java平台实现的引导程序和扩展类编译的。 It is important to use -bootclasspath and -extdirs when cross-compiling; 交叉编译时使用-bootclasspath和-extdirs非常重要; see Cross-Compilation Example below. 请参阅下面的交叉编译示例。

Java字节码与平台无关。

暂无
暂无

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

相关问题 不同的Java编译器(供应商不同)会产生不同的字节码 - Do different Java Compilers (where the vendor is different) produce different bytecode 跨不同编译器,版本,依赖项的java .class文件的差异是什么? - What is the variance of java .class files across different compilers, versions, dependencies? 同一个 javac 编译器是否可以编译相同的源文件集但生成不同校验和的类文件? - Is it possible for the same javac compiler to compile the same set of source files but produce class files of different checksums? 具有不同种子的Java Random实例确实会产生不同的序列,还是它们以相同的序列在不同的地方开始? - Do Java Random instances with different seeds really produce different sequences, or do they start at different places in the same sequence? 为什么两个仅在注释中不同的java文件会产生不同的类文件? - Why should two java files that differ only in comments produce different class files? IDE和编译器的/ t间距是否不同? (IntelliJ上的JAVA) - Do IDEs and compilers have different spacing for /t spacing? (JAVA on IntelliJ) 我如何证明 Object.hashCode() 可以为 Java 中的两个不同对象生成相同的哈希码? - How do I prove that Object.hashCode() can produce same hash code for two different objects in Java? Java 编译器是否与 Linux/Windows 上的编译器相同? - Is the Java compiler the same that is on Linux/Windows? 在Windows 7上:相同的路径,但Explorer和Java看到的文件不同于Powershell - On Windows 7: Same path but Explorer & Java see different files than Powershell Windows上可以使用哪些Java编译器? - Which Java compilers are available on Windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM