I have to develop a GUI for a dedicated piece of hardware that runs Debian. So, I got an example of the hardware it will run on, I installed the most current JRE (since it doesn't come with much installed), moved my code over from my development environment on a not-too-old Fedora-Core box, launched the app and got:
Exception in thread "main" java.lang.UnsupportedClassVersionError: mygui/MYGUI : Unsupported major.minor version 52.0
Thinking this odd, I did the typical yum update, then a build and got the same thing... So, deciding to just do the build on the new box itself, I installed the JDK. I then did a build using the newly installed JDK, which went fine but for one file - my-bad on a file-name / class-name mismatch - so I fixed it, and re-did the compile of just the one file and got:
warning: /opt/mygui/lib/fubar.class: major version 52 is newer
than 51, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
1 warning
This tells me that the compiler itself must have a bug! All it's looking at is the files it itself had just built! A team-mate suggested I remove the JRE, but I don't see how that helps since the compiler itself must have mislabeled the output.
Before you ask:
# javac -version
javac 1.7.0_111
# java -version
java version "1.7.0_111"
OpenJDK Runtime Environment (IcedTea 2.6.7) (7u111-2.6.7-1~deb8u1)
OpenJDK Zero VM (build 24.111-b01, interpreted mode)
I'm thinking someone else has seen this - anyone?
NOT DONE YET, seeing as that the compiler had only given a warning, I went to run it. The initial frame came up fine and I figured it was all fixed! YAY! But then I tried clicking on a menu item that brings up a new frame and instead of success, the new frame did NOT start and at the top of the error message dump I got:
Exception in thread "AWT-EventQueue-0"
java.lang.UnsupportedClassVersionError: mygui/secondframe : Unsupported
major.minor version 52.0
OK, so "it's broke." Anyone?
(NOTE: I found this other, similar question, but it's clearly different from my scenario.)
UPDATE: OK, fine, I already get it that the Java THINKS it has a version mismatch. People who are focusing on that are focusing on the wrong problem. The problem is "how the hell can it possibly think it's the wrong version? And, more importantly, what the hell do I do about it?!"
UPDATE TWO: At the suggestion of Laksitha Ranasingha (below), I ran the javap command he recommended and the answer was:
$ javap -v mygui.MYGUI | grep major
major version: 51
So, this goes to show that there's a bug with both the JDK and the "java" runtime environment (whether it came from the JRE I installed or the JDK I installed afterward, I don't actually know). For some reason BOTH the javac and java programs that are trying to either do more compiles of parts of the same package or run the package are getting errant data.
UPDATE THREE: I really don't care what the version is, and there are no outside libraries or apps. It was ALL - and I mean all of it - compiled by this same version. The ONLY reason "version 7" is involved is because the hardware vendor pointed me / us / their customers at it. Here's their product, released March, basically one year ago:
Here's where they tell us how to add Java. In sum, they say run:
# apt-cache search openjdk
Then pick the youngest one and then run:
# apt-get install openjdk-7-jre
I did that and later did:
# apt-get install openjdk-7-jdk
And then AFTER all this started, I did - and got:
# apt-get install openjdk-8-jdk
Package openjdk-8-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
I take it then that there is no version 8 available.
...SO... MAYBE I have to remove all this and install the package some other way. But how? It's not a powerful box. Compiles that take seconds on my dev system take over 20 minutes on this thing...
Fourth and maybe FINAL update: ...I think this question better belongs on either the ServerFault forum or perhaps the SuperUser forum since it's not a programming problem. I guess I'm old school, been here from the early days of this site when this was the only forum. But the down-votes are just a clue. Question is, I've seen questions "migrated" between forums but don't know how to do it. If anyone cares to comment how that can be done, it might make the people here happier they don't have to deal with non-programming problems while improving my odds. Or, I can just re-enter it.