2

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.

Community
  • 1
  • 1
mz496
  • 790
  • 1
  • 7
  • 13
  • You do not get this exception 'while trying to compile RMI code' if the 'code doesn't *run,*' or if you can identify that it had something to to with the `rebind()` call – user207421 Feb 22 '16 at 23:32

1 Answers1

1

I would say the JDK/JRE running the remote method is running on Java 7.

Gavin
  • 1,725
  • 21
  • 34
  • I am running everything on my local machine, so there is no question what version the client/server is using. Updated question. I'm trying to use the official tutorial now, it may change things – mz496 Feb 22 '16 at 08:59
  • There can be many JDK/JRE's on your machine, and if you are deploying the remote code into a container, tomcat for example it might being using JDK 7. I am a bit concerned by the version being *-internal. Never seen that before. – Gavin Feb 22 '16 at 09:07
  • Also while you PATH may point to a Java 8 versions of the JDK/JRE your JAVA_HOME may point elsewhere, currently my JAVA_HOME is blank as I set it on a per use case as I am working with Java 7 and 8 code bases. – Gavin Feb 22 '16 at 09:15
  • I do have some multiple JDK/JRE's installed, but if I selected the same one that should be fine, right? Also, the error occurs when I try to run the server code, so I think it's something with the RMI methods I'm using (simple tutorial methods from https://docs.oracle.com/javase/tutorial/displayCode.html?code=https://docs.oracle.com/javase/tutorial/rmi/examples/engine/ComputeEngine.java) – mz496 Feb 22 '16 at 09:16