User Tools

Site Tools


compilers:install_linux_bash
Return to Home page

Install Jflex, CUP and Java in Linux Bash Shell

Guide on how to install Java, Jflex and CUP in the Linux operating systems and using bash shell.

Jflex

To install Jflex on Ubuntu linux you can use apt tool, running in the shell the following command:

sudo apt install jflex

Java

The Oracle JDK can be downloaded at the following address https://www.oracle.com/java/technologies/javase-jdk13-downloads.html (at the moment of this guide the recommended version to download is jdk-13.0.2_linux-x64_bin.tar.gz).
Do not use Linux OpenJDK package.

Java installation

To install Java a possible guide is the following:

  • Create a folder into your home directory
    cd
    mkdir -p compilers
    cd compilers
  • Download into the folder the Java installation file jdk-13.0.2_linux-x64_bin.tar.gz
  • Decompress it
    tar xvfz jdk-13.0.2_linux-x64_bin.tar.gz
  • Change the symbolic links of Java programs (i.e., java, javac and jar) to the new installation of java with the following commands:
    cd /usr/bin/
    sudo ln -fs /home/skenz/compilers/jdk-13.0.2/bin/java .
    sudo ln -fs /home/skenz/compilers/jdk-13.0.2/bin/javac .
    sudo ln -fs /home/skenz/compilers/jdk-13.0.2/bin/jar .

CUP

To install CUP follow the following steps:

Download CUP

Download CUP at the following link: Download Cup version 11 (zip) with drawTree option (this version is an improved version w.r.t. normal release)

Important: do not use apt tool to install CUP, because it does not work correctly.

Installation

Execute next instructions:

  • Create in your home directory an installation folder for CUP:
    cd
    mkdir -p compilers
    cd compilers
  • Download the CUP files into the folder:
    wget https://www.skenz.it/repository/compilers/progs/java_cup_v11_draw_tree.zip
  • Decompress CUP files:
    unzip java_cup_v11_draw_tree.zip
  • Enter the CUP directory
    cd java_cup_v11_draw_tree/java_cup
  • Compile CUP:
    javac *.java runtime/*.java ../StdDraw.java

Configure environment variables

Before running CUP, 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/compilers/java_cup_v11_draw_tree/java_cup/
export PATH
CLASSPATH=.:/home/skenz/compilers/java_cup_v11_draw_tree/
export CLASSPATH

Note: to make active the new environment variables you must reopen a new shell. Remember that both $PATH and $CLASSPATH environmental variables have to contain the . (dot) that represents the current directory.

Check the installation

To verify that the programs have been correctly installed, run Jflex from the shell:

jflex

A graphical window should be opened.

For CUP you can type into the shell:

java java_cup.Main

and if it is correctly installed you see nothing in the terminal. To stop it you can press CTRL-c.

The installed CUP version contains also the functionality to draw into the screen the parse tree (this version was made especially for this course). To check this part you can type into the shell:

java java_cup.MainDrawTree

and if it is correctly installed you see nothing in the terminal. To stop it you can press CTRL-c.


If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it

You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/compilers/install_linux_bash
/web/htdocs/www.skenz.it/home/data/pages/compilers/install_linux_bash.txt · Last modified: 2020/03/15 21:49 by zioskenz

Privacy Policy