Course of Formal Languages and Compilers

Install JFlex and Cup in the Windows environment

Home > Install for Linux operationg systems
Installation guide for Java, Jflex and Cup on Windows 7 operating systems.

0 - Index

1 - Download necessary programs
2 - Java installation
3 - JFlex installation
4 - Cup installation
5 - Configuration

1 - Download necessary program

1.1 - Java

To download J2SE (Java 2 Standard Edition) connect a the Oracle Java page (
At the time of writing, the last version is 7 Update 3 (7u3). Click on the Download button in the JDK section and follow the instructions. Once you accept the license agreement, download the installation executable for your Windows architecture (both 32 and 64bit are available).

1.2 - JFlex

Download JFlex version 1.4.1 (zip)
Download JFlex version 1.4.1 (tar.gz)

1.3 - Cup

Download Cup version 10k (zip)
Download Cup version 10k (tar.gz)

2 - Java installation

Launch the previously download installation executable and follow the instructions. In this guide we suppose the chosen installation path is c:\j2sdk.

3 - JFlex installation

  • Create a folder where installing Jflex: in the proposed installation procedure c:\tooljava\jflex-1.4.1.
  • Decompress the file jflex-1.4.1.tar.gz or the file into the folder c:\tooljava\jflex-1.4.1

4 - Cup installation

The Cup installation is similar to the Jflex one:
  • Create a folder where installing Cup: in the proposed installation procedure c:\tooljava\cup.
  • Decompress the file java_cup_v10k.tar.gz into the folder c:\tooljava\cup

5 - Environment configuration

To execute Java, Jflex and Cup some Windows environment variables must be modified. On Windows 7 a graphical interface that allows to easily modify them is available. To access to the graphical interface go to Control Panel, System and Security, System. Click on Advanced system settings. In the opened window, click on the tab Advanced, click on the button Environment Variables in the botton right.

The window shows all the defined environment variables: those we are interested in are System variables.
The environment variable Path is used for launching a program saved in an arbitrary directory from the Windows shell. Modify the variable Path adding into the field Variable value the following string:
The variable CLASSPATH is used for indicating to the Java virtual machine where looking for the classes necessary to compile and execute a Java program: in this case Cup. Check if a variable CLASSPATH already exists; if not create it clicking on the button New and inserting into the field Variable name: CLASSPATH. In Variable value: insert c:\tooljava\cup;. if the variable has been created now or add ;c:\tooljava\cup;. if the variabie already existed.

The last step consists in modifying the file c:\tooljava\jflex-1.4.1\bin\jflex.bat:
@echo off
REM Please adjust the paths JFLEX_HOME and JAVA_HOME to suit your needs
REM (please do not add a trailing backslash)


REM only needed for JDK 1.1.x:

REM -------------------------------------------------------------------

set CLPATH=%JAVA_HOME%\lib\;%JFLEX_HOME%\lib\JFlex.jar

REM for JDK 1.1.x
%JAVA_HOME%\bin\java -classpath %CLPATH% JFlex.Main %1 %2 %3 %4 %5 %6 %7 %8 %9

REM for JDK 1.2
rem java -Xmx128m -jar %JFLEX_HOME%\lib\JFlex.jar %1 %2 %3 %4 %5 %6 %7 %8 %9

Substitute C:\JFLEX with c:\tooljava\jflex-1.4.1. Instead of C:\JAVA insert c:\j2sdk.

To verify that everything works correctly launch Jflex writing on the shell:
A graphical window should be opened.
Launch Cup writing on shell:
java java_cup/Main
on the shell will be prompt:
Opening files...
Parsing specification from standard input...

6 - Cup DrawTree installation

A modified version of Java CUP allows to graphically represent the derivation tree during the parsing processes. The package can be downloaded here as a compressed zip archive.
The installation procedure is pretty much the same of the normal CUP distribution:
  • Decompress the downloaded file in the same folder where JFlex/CUP were installed (c:\tooljava\ in the previous example)
  • Modify the environment variable CLASSPATH with the value c:\tooljava\tooljava\java_cup_v10k_drawTree

The last step is required for avoiding conflicts with the standard CUP installation. A parser with the support for the derivation tree drawing can be generated launching CUP with the command:
java java_cup.MainDrawTree parser.cup

Sponsored by,, and by

Policy sui Cookie