If you have still any problem, like “Could not find or load main class”, before continuing make completely sure about “System Variables
” and “CLASSPATH
” and do as link #1 or #2 or #3. For a complete explanation about causes, read this link
I assume that you did exactly as it is explained in link #3, and you can compile everything with no error, but the command “java Main inputfile.txt” is not working. It is mostly because Java can`t load the classes from “import java_cup.runtime.*;”, so “Main.class” is not known for Java (right now). All you need to do:
۱- move all the files [Main.java, parser.cup, scanner.jflex] to the root folder of “JavaCUP” and paste them there.
۲- compile everything again and run “java Main inputfile.txt”.
Note #1: JavaCUP needs the file “CUP$parser$actions.class” after compiling the parser, so never delete that.
Note #2: For a new project you just need to do as above, so move the previous files to a folder and create the new files.
Note #3: If you recompiled, Jflex may keep a copy of the previous file. Note that if there is/are (an) error(s) in new change(s), jflex may not compile the new changes and still calculate based on the previous file.