To download J2SE (Java 2 Standard Edition) connect to the Oracle Java Download page (http://www.oracle.com/technetwork/java/javase/downloads/index.html).
At the time of writing, the last versione is 7 update 3 (7u3). Click on Download in the JDK column and follow the instructions. Among the various packages, select the one for the Linux operating system, distributed as a compressed file (tar.gz extension).
Install java following the instructions provided by Oracle.
3 - JFlex Installation
To install jflex on Ubuntu linux you can use apt tool, running in the shell the following command: sudo apt-get install jflex
4 - Cup Installation
Important: do not use apt tool to install Cup, because it does not work correctly.
Simply follow these instructions:
Create in your home directory an installation folder for Cup: cd mkdir tooljava
Move to the installation folder of Cup: cd ~/tooljava
Create a folder where Cup will be installed: mkdir cup
Move the Cup installation file java_cup_v10k.tar.gz into the folder: mv java_cup_v10k.tar.gz ~/tooljava/cup
Enter the folder: cd cup
Decompress the installation file: tar xvfz java_cup_v10k.tar.gz
5 - 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 tar.gz compressed archive.
The installation procedure is pretty much the same of the normal CUP distribution:
Decompress the downloaded file in the same folder where Cup was installed: cd ~/tooljavatar xvf java_cup_v10k_drawTree.tar.gz
Delete the previous Cup installation: rm -fr cup
Rename the folder: mv java_cup_v10k_drawTree cup
A parser with the support for the derivation tree drawing can be generated launching CUP with the command: java java_cup.MainDrawTree parser.cup
5 - Environment Configuration
Before running the installed programs the Linux Shell environment variables must be configured. This guide refers to the bash shell.
To check the shell you are using, type the following command: echo $SHELL
To set the environment variables, open in your home directory the file .bashrc (the .bashrc file is executed by the shell each time you open a terminal and usually it is used to configure a shell): cd gedit .bashrc
After opening the .bashrc file, add on its top the following lines: PATH=$PATH:.:/home/skenz/cup/java_cup/ export PATH CLASSPATH=.:/home/skenz/cup/ export CLASSPATH
Note: to make active the new environment variables you must reopen a new shell.
7 - Check installation
To verify that the programs have been correctly installed, run Jflex from the shell: jflex
A graphical window should be opened.
Launch Cup writing into the shell: java java_cup/Main
the shell output will be:
Parsing specification from standard input...