简体   繁体   English

是否可以使用Oracle JDK编译java并在OpenJDK上运行代码?

[英]Is it possible to compile java using Oracle JDK and run the code on OpenJDK?

So is it possible to do all the development of a Java daemon (Apache Daemon) on a Windows 7 machine, then install the service on Ubuntu server (still have to search how to do that) which has OpenJDK installed ? 那么是否有可能在Windows 7机器上进行Java守护进程(Apache守护程序)的所有开发,然后在安装了OpenJDK的Ubuntu服务器上安装服务(仍然需要搜索如何操作)?

If yes, how can I identify the compatible versions of Java on both systems ? 如果是,我如何在两个系统上识别兼容的Java版本? I mean if I'm using Java 1.6 on windows, what is the least compatible OpenJDK version I should have on Ubuntu server ? 我的意思是如果我在Windows上使用Java 1.6,那么在Ubuntu服务器上应该具有的兼容性最差的OpenJDK版本是什么?

Mostly yes, but for corner cases it depends and should be carefully tested on stage that match closely to production configuration. 大多数情况下是的,但对于角落情况,它取决于并且应该在与生产配置紧密匹配的舞台上进行仔细测试。

Here are examples of compiler crash and test failure that occurs on OpenJDK, while the same snapshot of sources are green when build by Oracle JDK: 以下是OpenJDK上发生的编译器崩溃和测试失败的示例,而在Oracle JDK构建时,源的相同快照为绿色:

http://travis-ci.org/#!/plokhotnyuk/actors/builds/1948184 http://travis-ci.org/#!/plokhotnyuk/actors/builds/1948184

http://travis-ci.org/#!/plokhotnyuk/calculator/builds/1948194 http://travis-ci.org/#!/plokhotnyuk/calculator/builds/1948194

Java字节代码是可移植的,可以使用具有相同或更新版本的任何JVM来执行。

No, that's not but you have nothing to worry about this.Java is a standardized platform, you should be able to compile and run on any implementation of it. 不,那不是,但你没有什么可担心的.Java是一个标准化的平台,你应该能够编译并运行它的任何实现。 Just as long as you keep the version in mind. 只要你记住这个版本。 Java 7 software is not going to run on a Java 6 installation completely. Java 7软件不会完全在Java 6安装上运行。 Java 6 software does work on a Java 7 installation completely though. Java 6软件完全适用于Java 7安装。

If you have compiled for Java 1.6, you need at least OpenJDK 1.6. 如果您已经为Java 1.6编译,则至少需要OpenJDK 1.6。 There are rare cases where Hotspot and OpenJDK are different but since Hotspot is based on the OpenJDK you are more likely to see minor differences in build versions. 在极少数情况下,Hotspot和OpenJDK不同,但由于Hotspot基于OpenJDK,因此您更有可能看到构建版本中的细微差别。

Both JVMs comply with the JLS spec and IMHO are practically reference implementations. 两个JVM都符合JLS规范,而IMHO实际上是参考实现。 The OpenJDK is the open standard and a HotSpot is widely used as the commercial standard. OpenJDK是开放标准,HotSpot被广泛用作商业标准。 The releases are almost exactly the same. 这些版本几乎完全相同。

You can install the same version of Hotspot on Ubuntu if this is a real concern. 如果这是一个真正的问题,你可以在Ubuntu上安装相同版本的Hotspot。

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

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