0

I'm learning Antlr and trying to use the latest jar file (4.12.0) on a Windows 10 machine.

I get an error when I try to run it:

java -jar antlr-4.12.0-complete.jar

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/antlr/v4/Tool 
has been compiled by a more recent version of the Java Runtime (class file version 55.0), 
this version of the Java Runtime only recognizes class file versions up to 52.0

I uninstalled all versions of Java, cleared out my PATH and environment variables of any Java references, rebooted and downloaded what appears to be the latest Java version on the java.com downloads page. It says 'Recommended Version 8 Update 361 Release date: January 17, 2023'.

After the install (and a reboot for good measure) I'm disappointed to see the same error.

I don't work with Java and am unfamiliar with versions but I've tried to work this out. Right now I've found a 'Microsoft Build of OpenJDK', a 'JDK 20 reached General Availability on 21 March 2023' and a 'Java SE Development Kit 20' and am doing some reading, but am feeling thoroughly confused by it all. I think I just need a Java runtime of the right version but haven't found one yet.

So, help please, what do I need to install to get Antlr working?

Elliveny
  • 2,159
  • 1
  • 20
  • 28
  • Ok, so I installed microsoft-jdk-17.0.6-windows-x64.msi from https://learn.microsoft.com/en-us/java/openjdk/download. This has given me a new java.exe in "C:\Program Files\Microsoft\jdk-17.0.6.10-hotspot". After rebooting, java --version gives me 'openjdk 17.0.6 2023-01-17 LTS - OpenJDK Runtime Environment Microsoft-7209853 (build 17.0.6+10-LTS) - OpenJDK 64-Bit Server VM Microsoft-7209853 (build 17.0.6+10-LTS, mixed mode, sharing)' and now I get the 'ANTLR Parser Generator Version 4.12.0' help when I execute the jar file :-) - Still wondering if the JDK was the best choice though? – Elliveny Apr 01 '23 at 07:31
  • As far as I'm aware, the java.com site is only retained and only offers Java 8 for "historic reasons". So the fact it recommends "Version 8 Update 361" has no bearing on what the wider Java community does and uses. For example, if you go to https://www.java.com/en/, it has a blurb _"Are you a software developer looking for JDK downloads?"_ which points you to https://www.oracle.com/java/technologies/downloads/ (which right now will recommend Java 17 and/or Java 20). Also there are a lot of different "vendors" for Java: Oracle, Eclipse Adoptium, Microsoft, Azul, IBM and others. – Mark Rotteveel Apr 02 '23 at 09:07
  • Thanks @MarkRotteveel - it seems bizarre to me that Java 8 has a recent release date, it's very misleading. I see my question was closed, with reference to a 'duplicate' which I did see, but which has such an overwhelming number of replies and which discusses subjects way outside the issue I was trying to fix that I couldn't see an answer there. I hope this question stays around for the benefit of others who are looking for a simple answer to 'how can I get the latest version of Antlr running on Windows 10'. – Elliveny Apr 03 '23 at 06:24
  • 1
    Java 8 is still maintained, just like Java 11, Java 17, and Java 20 (Java 20 is supported until the release of Java 21). In any case. from the accepted answer on the duplicate, you should be able to understand the exception, and that you need Java 11 or higher to be able to run classes of "class file version 55.0". – Mark Rotteveel Apr 03 '23 at 07:21

0 Answers0