When you are invoking
java JFlex.Main xxx.flex
You ask java to load the JFlex.Main
class and passing xxx.flex
as parameter. As you do not tell java where is that JFlex.Main
class, java is searching it in its classpath, and if you did not add the JFlex jar file to the class path, it results in the error message
Error: Could not find or load main class JFlex.Main
BTW, class names and namespaces are case-sensitive : in the JFlex jar file, the Main
class is in the jflex
directory, not JFlex
so you need to invoke the jflex.Main
class... unless you are using the a JFlex version prior to 1.5 where JFlex
is legal.
To let java find the class:
- either change the system class path (with the environment variable
$CLASSPATH
- or %CLASSPATH%
in windows)
- or just provide the location of the jar file the the
java
command with the -cp
parameter
For example:
java -cp path/to/jflex-1.6.0.jar jflex.Main xxx.jflex
If the jar is in the current directory, you can just use
java -cp jflex-1.6.0.jar jflex.Main xxx.jflex
Or more simply, as it is an executable jar, you can omit the main class
java -jar jflex-1.6.0.jar xxx.jflex
Similarly, it seems that java is missing the CUP jar file while processing your yyy.cup
file, you can fix it like for JFlex with
java -cp java-cup-11a.jar java_cup.Main yyy.cup
or
java -jar java-cup-11a.jar java_cup.Main yyy.cup