razzjazz192
Posts: 18
Joined: Tue Mar 30, 2021 10:33 pm

UnsupportedClassVersion when compiling on different computer and running on PI

Mon May 03, 2021 12:56 pm

Hi there,

Very frustrated...I am trying to run through some simple and basic networking tutorials that should allow me to communicate with my raspberry pi from another computer on my internal home network, and am running into the kind of problem that drives me crazy: you follow all the instructions to a t, you understand the logic, but technical difficulties nonetheless reign supreme: I have some java code that compiles and works well on my Windows 10 system, which has this version of Java: Java version "16", 2021-03-16 Java Runtime Environment: build 16 + 36 - 2231 Java HotSpot 64-bit Server VM Build 36 + 2231(mixed mode, sharing). On the Raspberry Pi, I have these Java speciications:

openjdk 11.0.9.1 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-post-Raspbian-1deb10u2)
OpenJDK Server VM (build 11.0.9.1+1-post-Raspbian-1deb10u2, mixed mode)


This is the error message I am recieving from the compiler when I run my java programs:

Error: LinkageError occurred while loading main class echoclient.EchoClient
java.lang.UnsupportedClassVersionError: echoclient/EchoClient has been compiled by a more recent version of the Java Runtime (class file version 60.0),

. Now, assuming the logicis correct in my code, it must then be a conflict between the standard Java runtie environment, and openjdk......if so, what would I need to do to write Java software on my Windows computer and run it in my Pi. I believe this has been a source of many many frustrating hours for me, and I hope someone can give me some advice. I very much appreciate any time anyone can offer, as usual. If I could not stumble so much on stuff like this, I would be happy.
Last edited by razzjazz192 on Mon May 03, 2021 1:04 pm, edited 1 time in total.

razzjazz192
Posts: 18
Joined: Tue Mar 30, 2021 10:33 pm

Re: UnsupportedClassVersion

Mon May 03, 2021 1:03 pm

I even set up my Netbeans compiler with a RemotePlatform, got a successfull connection to my Raspberry Pi, but when I go to Project Properties and under categories attempt to select the remote platform I just established, it will not let me. So very frustrating. But I won't give up. I'd rather pullall my hair out and not clean my house until I figure it out. With the remote platform, I should be able to compile with the openjdk already established on my raspberry pi, but alas....technical difficulties.........

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13971
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: UnsupportedClassVersion when compiling on different computer and running on PI

Mon May 03, 2021 3:24 pm

Cross-platform use of Java doesn't look like a "beginners" subject, so moving to "java".

razzjazz192
Posts: 18
Joined: Tue Mar 30, 2021 10:33 pm

Re: UnsupportedClassVersion when compiling on different computer and running on PI

Mon May 03, 2021 3:28 pm

Sorry about that....To update abut my dillema: I have downgraded my Java runtime environment to Java 11, and have made sure the environment variables are all in place. The files, again, produce the exact same result, even though the runtime environment on my PI is 11 and the one on my Windows platform is 11....the only difference seems to be that one is the openjdk framework, whereas the other, on the windows platform is simply the jdk. I am about to test on my non-PI linux and see what happens. So frustrated....I feel like I'm breaking my neck over something really obvious

razzjazz192
Posts: 18
Joined: Tue Mar 30, 2021 10:33 pm

Re: UnsupportedClassVersion when compiling on different computer and running on PI

Mon May 03, 2021 4:48 pm

I thought it was write once, run everywhere....... :x :x

razzjazz192
Posts: 18
Joined: Tue Mar 30, 2021 10:33 pm

Re: UnsupportedClassVersion when compiling on different computer and running on PI

Mon May 03, 2021 5:10 pm

Solved the problem by downgrading to JDK 11 on all of the systems external to the pi. Apparently JDK 16 has some problems with the Remote Platform access in netbeans, I don't fully understand the issue, But I do know that I can now compile on the pi from an external system, and that solves days of frustration. So happy to go back to actual programming. This kind of thing makes me feel dumber than a toaster

knute
Posts: 692
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Re: UnsupportedClassVersion when compiling on different computer and running on PI

Tue May 04, 2021 2:06 am

There is a compile option --release ?? to set the version level of the output class files. I keep my compiler up to date but often use --release 11 or sometimes even 8 if I think the program will be run by somebody using an ancient runtime.

Heater
Posts: 18232
Joined: Tue Jul 17, 2012 3:02 pm

Re: UnsupportedClassVersion when compiling on different computer and running on PI

Tue May 04, 2021 6:42 am

razzjazz192 wrote:
Mon May 03, 2021 4:48 pm
I thought it was write once, run everywhere....... :x :x
Sun Microsystems spent more money on promoting Java than any other programming language in history. That was just an advertising catch phrase. Sadly Sun went bankrupt and programmers fell for the Java hype. Best avoided in the modern world where we have much better alternatives.
Memory in C++ is a leaky abstraction .

mattlewis
Posts: 135
Joined: Sat Jan 12, 2013 3:05 pm
Location: UK
Contact: Website

Re: UnsupportedClassVersion when compiling on different computer and running on PI

Tue May 04, 2021 6:11 pm

I have to disagree :-)

If you aren't already, you should consider a build tool such as Maven or Gradle. The following example Maven properties configure the output class files for JDK 8 regardless of the JDK:

Code: Select all

<properties>
  <maven.compiler.source>8</maven.compiler.source>
  <maven.compiler.target>8</maven.compiler.target>
</properties>
My diozero library runs on every SBC that I have managed to get my hands on - all flavours of Pi with both 32-bit as well as 64-bit Raspbian, Armbian plus many others. It even manages to provide the same API for Arduino devices.
http://www.diozero.com/

Return to “Java”