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

╄→尐↘猪︶ㄣ 提交于 2020-01-01 08:46:35

问题


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 ?

If yes, how can I identify the compatible versions of Java on both systems ? I mean if I'm using Java 1.6 on windows, what is the least compatible OpenJDK version I should have on Ubuntu server ?


回答1:


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:

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

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




回答2:


Java byte code is portable and can be executed using any JVM that has same or newer version.




回答3:


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. 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 6 software does work on a Java 7 installation completely though.




回答4:


If you have compiled for Java 1.6, you need at least 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.

Both JVMs comply with the JLS spec and IMHO are practically reference implementations. The OpenJDK is the open standard and a HotSpot is widely used as the commercial standard. The releases are almost exactly the same.

You can install the same version of Hotspot on Ubuntu if this is a real concern.



来源:https://stackoverflow.com/questions/11629444/is-it-possible-to-compile-java-using-oracle-jdk-and-run-the-code-on-openjdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!