简体   繁体   中英

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 ?

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 ?

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

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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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