简体   繁体   中英

Java Unsupported major minor Version 52? Why does this happen though I didn't use new features from Oracle Java 1.8?

I am just learning Java. I compiled and created a jar file for a simple quiz game with a light GUI. All done from Ubuntu 14.04 terminal manually with ' javac -d ... ' and ' jar -xvmf... '

Here are my version details:

java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

javac 1.8.0_11

I followed a tutorial dealing with Java SE 5.0 for creating it, so I guess no new features from '1.8' were used. It compiled and it worked fine for me. When my friend who uses OpenJDK (latest version available) in Ubuntu 14.04 tried running it he received a lot of errors including Unsupported major minor ... 52... .

I don't have the full verbose output from the terminal. Is there any way to avoid this and why is this happening though I didn't use use any new features specific to the latest version?

I thought Java was supposed to be "Write Once ,Run Everywhere" , and compatibility issues with even the simplest of things with just a slightly little older version involved makes me rethink things!

The version of the byte code doesn't depend on whether you use Java 8 new features or not. It simply depends on which compiler you use. A Java 8 compiler will by default produce Java 8 bytecode, unless you use the option -target to specify an earlier version.

Side note: your friend is not using the latest version of OpenJDK (which is Java 8), otherwise, he would not get this exception.

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