Reputation: 1133
I use IntelliJ 14.1.3 and its Antlr4-Plugin to code grammar code with Antlr4 on a Mac Yosemite. I added the antlr-4.5-complete.jar as library and with the plugin tool i create lexer and parser files.
Trying to use those files I get some expections stating that antlr4.5 generated the code but that there is a runtime of antlr in version 4.4. Where does this version come from as I never installed it?
I already read this post How to configure antlr4 plugin for Intellij IDEA and especially this section:
it appears that the plugin uses the version of ANTLR it contains rather than the version of ANTLR you are using in your project as a library, so using the plugin it is possible to generate Java source code that will not compile within your project.
but it did not help as it does not state how to solve the problem.
The problem occurs only on my Mac, Windows does not seem to be affected.
Here is the stack trace:
Exception in thread "main" java.lang.ExceptionInInitializerError
at GeneratePlayerAIShots.main(GeneratePlayerAIShots.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: org.antlr.v4.runtime.RuntimeMetaData$VersionMismatchException: ANTLR Runtime version 4.5 used for parser compilation does not match the current runtime version 4.4
at org.antlr.v4.runtime.RuntimeMetaData.checkVersion(RuntimeMetaData.java:371)
at PlayerAIShotsLexer.<clinit>(PlayerAIShotsLexer.java:13)
... 6 more
Upvotes: 0
Views: 1414
Reputation: 1133
I found a solution as it seems and I would like to let everybody participate in reading my solution who it concerns:
The problem was that my installation on my MacBook had an outdated antlr-4.4.jar. It was undetected within the folder "/Library/Extensions/" and therefor has been used instead of the added libraries in IntelliJ and classpath (version 4.5).
I exchanged the old jar with the new version and deleted all generated Lexer/parse files and so on within the project. In the end it works :-)
Upvotes: 0