Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup Javacc in windows 10

How do I install javacc in Windows 10?

I visited https://javacc.github.io/javacc/, but there's no clear instruction to set it up on Windows.

like image 997
cha Avatar asked Dec 22 '22 18:12

cha


2 Answers

Update: I have made some changes to the steps, and provided some notes about those changes at the end.


I know the OP switched to using version 6, but here are the instructions for version 7:

(Version 7.0.5, to be precise.)

Set-Up:

  1. Go to the "Getting Started" page here.

  2. Download the zip file from the "Source(zip)" link.

  3. Unzip that into a directory of your choosing. I chose a new empty directory E:\javacc. That ended up giving me everything in E:\javacc\javacc-7.0.5.

  4. Create a new target directory. For me, that was E:\javacc\javacc-7.0.5\target.

  5. NO NEED TO DO THIS: Download the jar file from the "Getting Started" page, using the "Binaries" link. That gives you a file javacc-7.0.5.jar.

  6. Locate the javacc.jar file in the bootstrap directory. Copy that file to the new target directory.

  7. Add the scripts directory (for me: E:\javacc\javacc-7.0.5\scripts) to your PATH environment variable. I assume that does not need specific instructions.

Verify:

To test the installation:

  1. Open a new command prompt (to pick up the PATH changes), and navigate to the javacc installation directory (for me: E:\javacc\javacc-7.0.5).

  2. Execute the following command:

javacc

This should give you a screenful of output, starting with:

E:\javacc\javacc-7.0.5>java -cp target/javacc.jar javacc
Java Compiler Compiler Version 7.0.5 (Parser Generator)

Usage:
    javacc option-settings inputfile

Similarly, you should be able to run the jjdoc and jjtree commands.


Update

The above steps were, indeed, unnecessarily complicated - as noted in comments. I have made some simplifications (used with v7.0.10). Those are shown above.

The objective when using the JavaCC zip file is to be able to execute each JavaCC command (e.g. javacc) on the command line directly.

You can run JavaCC commands using only the JAR file, as follows:

java -cp javacc.jar javacc

Using this approach, you will not have access to javacc (or the other commands) directly on the command line: they will not be on your PATH.

like image 184
andrewJames Avatar answered Jan 02 '23 11:01

andrewJames


You can follow the same steps in the Installation part of the guide.

https://javacc.github.io/javacc/#getting-started

After you have unzipped the downloaded file into a new directory, you need to add the path of the folder to your PATH variable in Windows. To do that, follow this guide:

https://www.java.com/en/download/help/path.xml

like image 28
Bruno Gava Guerra Avatar answered Jan 02 '23 12:01

Bruno Gava Guerra