1

A project I just started working on uses JFlex, and when I try and compile the project using ant, I get the following error:

java.lang.NoSuchMethodError: java_cup.runtime.lr_parser.getSymbolFactory()Ljava_cup/runtime/SymbolFactory

What's causing this? I have the JFlex jar downloaded, and am using it in my project.

Brad Parks
  • 66,836
  • 64
  • 257
  • 336

2 Answers2

3

Turns out to use the jflex ant tasks, you need to download JFlex from here, unzip it somewhere, then copy the jflex-1.6.1/lib/* files to your ant/lib/ folder, and try again.

Brad Parks
  • 66,836
  • 64
  • 257
  • 336
3

I had the same problem when using both JFlex.jar and cup_v10k.jar in the same project in IntelliJ.

The problem lied in the cup_v10k.jar, where the java_cup.runtime.lr_parser class also exists, and the method getSymbolFactory() does not exist in that class.

IntelliJ didn't know which jar to trust when searching for the lr_parser class, and chose the lexicographically first jar - cup_v10k.jar.

My solution/hack was to rename the cup_v10k.jar to something lexicographically after JFlex.jar, for example zcup_v10k.jar. IntelliJ was then able to find the right lr_parser class.