Tuesday, 7 March 2017

Unsupported major.minor version 52.0 with Java RMI; java/javac 1.8 on Ubuntu

NOTE: This question is not a duplicate! It's more about RMI than it is about the UnsupportedClassVersionError



I get the UnsupportedClassVersionError while trying to run RMI code. All my other code runs fine, but I'm trying to follow an RMI tutorial, and the code doesn't run. I'm running Linux Mint 17.1 Rebecca and I am not using any IDE. I am also compiling and running all code on my local machine through command line, so there can be no question as to what version of java/javac I am using.



Output of java -version:



openjdk version "1.8.0_72-internal"
OpenJDK Runtime Environment (build 1.8.0_72-internal-b15)
OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode)


Output of javac -version:



javac 1.8.0_72-internal


I know there are a lot of duplicates of this question, but seeing as all my other code runs fine, and java and javac are the same version, is there any reason that RMI code in particular (for which all tutorials happen to be ancient) might cause this error? I followed this tutorial: Java RMI



Solution:



I solved the issue by narrowing down the problem to the call to rebind() in the tutorial and with a tip from this other answer. I had to run



sudo update-alternatives --config rmiregistry


in order to set the version correctly, as I had done before for java and javac. That explains why all my other code ran properly, but RMI didn't.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...