User Tools

Site Tools


compilers:install_windows
Return to Home page

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Previous revision
compilers:install_windows [2020/05/25 11:33]
compilers:install_windows [2021/03/19 09:14] (current)
zioskenz [Java]
Line 1: Line 1:
 +====== Install Jflex, CUP and Java in Windows ======
 +Guide on how to install Java, Jflex and CUP in the Windows operating system.
 +
 +<html><iframe width="560" height="315" src="https://www.youtube.com/embed/0lphu1CAsPw" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></html>
 +
 +
 +==== Java ====
 +The Oracle JDK can be downloaded at the following address [[https://www.oracle.com/java/technologies/javase-downloads.html]], choosing the one marked as **Windows x64 Installer** (at the moment of this guide the recommended version to download is ''jdk-14_windows-x64_bin.exe'').
 +
 +==== JFlex and CUP ====
 +You can choose to install JFlex and CUP either using the installer we provide you or by following the installation steps manually.
 +
 +
 +=== Manual installation ===
 +1. Create a folder named ''FLC_Tools'' in the desired path (e.g. ''C:\Program Files'', ''C:\Program Files (x86)'', or in your Desktop).
 +
 +2. Copy the folders ''java_cup_v11_draw_tree'' and ''jflex-1.8.2'' (that you can find in [[https://www.skenz.it/repository/compilers/progs/flctools.zip|this zip file]]) inside ''FLC_Tools'', in order to have the two paths ''//[installdir]//\FLC_Tools\java_cup_v11_draw_tree'' and ''//[installdir]//\FLC_Tools\jflex-1.8.2'' (where ''//[installdir]//'' is the path you chose in step 1).
 +
 +3. Open a command prompt with administrator privileges and execute:
 +
 +<code>
 +cd [installdir]\FLC_Tools\java_cup_v11_draw_tree\java_cup
 +</code>
 +<code>
 +javac *.java runtime\*.java ..\StdDraw.java
 +</code>
 +
 +4. Go to control Settings -> System -> About -> System Info -> advanced system settings, or BETTER search for "environment variables" and click on "Edit the system environment variables". Then go to Environment Variable.
 +
 +5. Create an environment variable called ''JFLEX_HOME'', with value ''//[installdir]//\FLC_Tools\jflex-1.8.2'' (replacing ''//[installdir]//'' appropriately).
 +
 +
 +5. Add to the ''Path'' environment variable the values ''//[installdir]//\FLC_Tools\jflex-1.8.2\bin'' and ''//[installdir]//\FLC_Tools\java_cup_v11_draw_tree\java_cup;.'' (remember the dot ''.'').
 +
 +6. Add to the ''CLASSPATH'' environment variable (or create it if it does not exist already) the value ''//[installdir]//\FLC_Tools\java_cup_v11_draw_tree;.'' (remember the dot ''.''), appropriately separating it (using the '';'' symbol) from any preexisting values.
 +
 +7. Change the ''FLC_Tools'' folder privileges and give the Users full control. To do that, right click on the ''FLC_Tools'' folder and click //Properties//. In the new window, move to the //Security// tab and click the //Edit// button next to //"To change permissions, click Edit"//. Select the //Users// group and click on //Full control// under //Allow//. Then //Apply//, //OK//, and then again //OK//.
 +
 +==== Check installation ====
 +To verify that the programs have been installed correctly, open a command prompt (cmd) and enter:
 +<code>
 +jflex
 +</code>
 +A graphical window should be opened.
 +
 +For CUP you can type into the command prompt:
 +<code>
 +java java_cup.Main
 +</code>
 +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 command prompt:
 +<code>
 +java java_cup.MainDrawTree
 +</code>
 +and if it is correctly installed you see nothing in the terminal. To stop it you can press ''CTRL-c''.
 +
 +==== Complete Check of installation ====
 +  - Download the following code: [[https://www.skenz.it/repository/compilers/classroom/exClass-2.zip|exClass-2.zip]]
 +  - Decompress in a directory end type in a terminal the following commands
 +<code>
 +jflex scanner.jflex
 +java java_cup.MainDrawTree parser.cup
 +javac *.java
 +java Main example_expr.txt
 +</code>
 +
 +=== Other possible installation method (with Installer) NOT RECOMMENDED ===
 +The setup package requires that the JDK is installed on the machine, so make sure you did not skip the previous step or you already had a working Java installation. Download the setup file at the following address [[https://www.skenz.it/repository/compilers/progs/flctools.exe|FLC Tools installer]] and run it with administrator privileges.\\
 +FLC Tools installs both Jflex and CUP and properly configures the system environment variables. To check if everything works, please refer to the //Check installation// paragraph.\\
 +If you have problems using the installer, try following the instructions in the //Manual installation)// paragraph.
 +
  

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_windows?rev=1590399213&do=diff