compilers:install_linux_bash
Return to Home page
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?rev=1584305353&do=diff
Differences
This shows you the differences between two versions of the page.
— | compilers:install_linux_bash [2024/04/08 22:34] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== 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 '' | ||
+ | <code bash> | ||
+ | sudo apt install jflex | ||
+ | </ | ||
+ | |||
+ | ==== Java ==== | ||
+ | The Oracle JDK can be downloaded at the following address [[https:// | ||
+ | **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 '' | ||
+ | * Decompress it<code bash> | ||
+ | tar xvfz jdk-13.0.2_linux-x64_bin.tar.gz | ||
+ | </ | ||
+ | * Change the symbolic links of Java programs (i.e., '' | ||
+ | cd /usr/bin/ | ||
+ | sudo ln -fs / | ||
+ | sudo ln -fs / | ||
+ | sudo ln -fs / | ||
+ | </ | ||
+ | |||
+ | ==== CUP ==== | ||
+ | To install CUP follow the following steps: | ||
+ | === Download CUP === | ||
+ | Download CUP at the following link: [[https:// | ||
+ | |||
+ | **Important: | ||
+ | |||
+ | === 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:// | ||
+ | </ | ||
+ | * Decompress CUP files:< | ||
+ | unzip java_cup_v11_draw_tree.zip | ||
+ | </ | ||
+ | * Enter the CUP directory< | ||
+ | cd java_cup_v11_draw_tree/ | ||
+ | </ | ||
+ | * Compile CUP:< | ||
+ | javac *.java runtime/ | ||
+ | </ | ||
+ | |||
+ | === 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: '' | ||
+ | |||
+ | To set the environment variables, open in your home directory the file '' | ||
+ | <code bash> | ||
+ | cd | ||
+ | gedit .bashrc | ||
+ | </ | ||
+ | |||
+ | After opening the '' | ||
+ | <code bash> | ||
+ | PATH=$PATH: | ||
+ | export PATH | ||
+ | CLASSPATH=.:/ | ||
+ | export CLASSPATH | ||
+ | </ | ||
+ | |||
+ | **Note:** to make active the new environment variables you must reopen a new shell. Remember that both '' | ||
+ | |||
+ | ==== Check installation ==== | ||
+ | To verify that the programs have been installed correctly, open a command prompt (cmd) and enter: | ||
+ | < | ||
+ | jflex | ||
+ | </ | ||
+ | A graphical window should be opened. | ||
+ | |||
+ | For CUP you can type into the command prompt: | ||
+ | < | ||
+ | java java_cup.Main | ||
+ | </ | ||
+ | and if it is correctly installed you see nothing in the terminal. To stop it you can press '' | ||
+ | |||
+ | 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 command prompt: | ||
+ | < | ||
+ | java java_cup.MainDrawTree | ||
+ | </ | ||
+ | and if it is correctly installed you see nothing in the terminal. To stop it you can press '' | ||
+ | |||
+ | ==== Complete Check of installation ==== | ||
+ | - Download the following code: [[https:// | ||
+ | - Decompress in a directory end type in a terminal the following commands | ||
+ | < | ||
+ | jflex scanner.jflex | ||
+ | java java_cup.MainDrawTree parser.cup | ||
+ | javac *.java | ||
+ | java Main example_expr.txt | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Other resources ==== | ||
+ | === AUR packet for Arch Linux === | ||
+ | For the Arch Linux architecture you need to extract the following archive (i.e., file polito-cup.tgz) and execute the command '' | ||
+ | |||
+ | Archive download: [[https:// | ||
+ | |||
+ | (This latter procedure was not verified by the professor. If you found it has some problems, please communicate it to the professor) | ||
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?rev=1584305353&do=diff