• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

UnsupportedClassVersionError

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,   I recently installed NetBeans 10 on my windows 7 PC.  A program called DateServer has been written and compiled on NB10.  If DateServer is run within the IDE, it operates fine.  However if I run DateServer from the command line it throws an error "UnsupportedClassVersionError".  

The JRE on my PC is SE 1.8.0_231

NB 10 is compiling with SE 11.0.2+9-LTS

Paraphrasing the error message:  DateServer has  been compiled with version 55.0, this java runtime only recognizes class file versions up to 52.0

I am hesitant to install the latest JRE on my machine since it may break operation of some legacy programs.

Is it possible to direct NB10 to compile DateServer with SE 1.8.0 ?  

Thank you for your help.

Roy
 
Marshal
Posts: 76405
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

R Nordstrom wrote:. . . I am hesitant to install the latest JRE on my machine since it may break operation of some legacy programs.

Which legacy programs? Why do you think they will break?

Is it possible to direct NB10 to compile DateServer with SE 1.8.0 ?  . . .

It should be possible to set the JDK for that program to be Java8. Try project→properties. I am not sure what you should do next.
 
Saloon Keeper
Posts: 26019
186
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java is not Internet Explorer. You can install as many different versions of Java on a single machine as you want. My current desktop has 9 different Oracle JVMs plus the open-source JVM that came with the latest OS release. You can then associate any JVM with any Java application you wish, and in the case of a product like an IDE, you can generally associate any specific JVM with any specific project within the IDE.

And that's not even counting the regression options on the javac and java commands themselves.

Java's innate backwards compatibility is a point of pride. As I like to recount, once I got a 3am phone call on a Windows app that needed a 1-line change to fix. In order to update the failing app, I had to un-install my current Visual Studio, install a 2-year old version, apply the 2-year old patches and came perilously close to have to install an older copy of Windows plus the service packs for the older version of Windows. This is NOT what I want to be doing before the sun comes up.

Java, on the other hand, was designed with the same longevity that keeps 40-year old COBOL programs running on IBM mainframes. Plus, Java has a deprecation mechanism so that if a feature becomes obsolete, you can still build and run in an emergency and upgrade when there's less panic.

So there's minimal risk here.

Note that the environment variable JAVA_HOME is often of help here. JAVA_HOME is not an official part of Java, but it's the conventional designator for the location of the JRE or JDK to be used to run a specific app. Not all apps employ it. For example, the Eclipse IDE locates the version of Java that Eclipse itself runs under from an internal configuration file. But a lot of other apps, such as Tomcat, Ant and Maven, and so forth do reference JAVA_HOME. Since environment variables are unique to each shell instance, you can have a command window where JAVA_HOME points to Java 11 running Ant and another command window whose JAVA_HOME points to Java 13 running Tomcat. And maybe even a third command window running another Tomcat under Java 11!

 
Rancher
Posts: 144
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

R Nordstrom wrote:. . . I am hesitant to install the latest JRE on my machine since it may break operation of some legacy programs.

Which legacy programs? Why do you think they will break?


Well, although this is not really a fault of Java but of the "internal hacks" used to do what it did: modded Minecraft with versions up to 1.12. The reason is the modding framework called "Forge": it uses some, well, some here would call it "dirty hacks" to add modding support to standard Minecraft. "Vanilla" Minecraft itself can run on any Java version from 6 and up (can be 7 or 8, not sure) - but as the announced official modding api was never implemented by the original devs around Notch and Mojang the community had to come up with its own stuff. This led to very dirty code use internal classes in sun and com.sun packages, wich we all know shouldn't be used. So, when try to run a modded minecraft between early beta builds up to 1.12 it fails pretty early with some strange class cast exception noting that the system class loader is no longer a instance/subclass of URLClassLoader.
I know this is a very rare edge case caused by some strange and odd code - but there're some issues broken by newer releases.
 
Tim Holloway
Saloon Keeper
Posts: 26019
186
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, we've been discussing some mainline breakage in the latest Java. Oracle is apparently not quite so meticulous as Sun was.

But definitely including sun.com components was asking for it.

Still, as I said, there's no problem having multiple JVMs on a single computer, even so.
 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic