Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone, please I need your help with installing javacc (java complier complier). I downloaded the latest version (7.0.9) from JavaCC | The most popular parser generator for use with Java applications.[^] unzipped it, copied the files to the directory where java (jdk1.8.0_201 and jre1.8.0_261) are installed on my machine. I renamed the folder to javacc.jar as instructed on the site above, copied the script's directory path (there's no bin folder in this version) and added it to my Environment Variable. But when I ran the command javacc from my terminal I got this error -
"Could not find or load main class javacc"
. Please how can I get javacc 7.0.9 to work on my machine? I'm using a Windows 8.1 laptop. Also, java and javac command from my terminal is running smoothly on my machine. Thanks for any help.

What I have tried:

javacc command from terminal - error: could not load or find main class
java command from terminal - works fine
javac command from terminal - works fine
Posted
Updated 13-Oct-20 23:36pm
Comments
Richard MacCutchan 14-Oct-20 4:09am    
What is the exact command you typed at the console?
UT7 14-Oct-20 5:40am    
@Richard MacCutchan, the command I used in my console is javacc

You might be missing reference of JavaCC in system path variable.

Quote:
The download should have placed into your file system either a ZIP or GZIP file containing the JavaCC software. You should go to the directory where the archive was installed and unzip it's contents. That completes your installation.

Once you have completed installation, add the bin directory within the JavaCC installation to your path. The javacc, jjtree, and jjdoc invocation scripts/executables reside in this directory.


look at: How do I set or change the PATH system variable?[^]

Refer a similar question discussed here: jar - Getting started with JavaCC[^]
 
Share this answer
 
Comments
UT7 14-Oct-20 4:41am    
@Sandeep Mewara, I've done all what you mentioned. I unzipped the file, copied it to the directory where my jdk and jre are, I also copied the path to the script's directory path and added it to my system variable path. That's why its not showing "javacc is not recognized as an internal or external command". Also, there isn't any bin folder in this javacc version and after doing all that I mentioned above I'm still getting the error - Could not find or load main class.
Richard MacCutchan 14-Oct-20 4:43am    
I ask again, "what is the exact command you type at the console?
UT7 14-Oct-20 5:41am    
@Richard MacCutchan, the command I used is javacc.
Sandeep Mewara 14-Oct-20 4:54am    
Here from the same link you shared tht you downloaded the files:

Installation

To install JavaCC, navigate to the download directory and type:

$ unzip javacc-7.0.9.zip
or
$ tar xvf javacc-7.0.9.tar.gz

Then place the binary javacc-7.0.9.jar in a new target/ folder, and rename to javacc.jar.

Once you have completed installation add the scripts/ directory in the JavaCC installation to your PATH. The JavaCC, JJTree, and JJDoc invocation scripts/executables reside in this directory.
UT7 14-Oct-20 4:58am    
@Sandeep Mewara, the command that I used in my console is javacc
Yes, that's the same link that I shared.
I followed the instructions that is stated above, i added the scripts/ directory in the Javacc installation to my path. Thank you.
I have got it working and the only thing I can think, is that you may have missed a step in the installation:
Then place the binary javacc-7.0.9.jar in a new target/ folder, and rename to javacc.jar.

If you did this then make sure that the target folder is in the correct place, which is in the javacc directory at the same level as the scripts directory.

No doubt they could have made the installation process easier.
 
Share this answer
 
Comments
UT7 14-Oct-20 5:47am    
Please could explain what you mean by "....the same level as the scripts directory."?
Richard MacCutchan 14-Oct-20 6:07am    
It means that it should be in the javacc folder that contains the scripts folder. So a directory listing will look like:
 Directory of C:\Users\rjmac\Downloads\javacc\javacc

14/10/2020  10:39    <DIR>          .
14/10/2020  10:39    <DIR>          ..
14/10/2020  10:07               662 .editorconfig
14/10/2020  10:07               410 .gitattributes
14/10/2020  10:07    <DIR>          .github
14/10/2020  10:07               668 .gitignore
14/10/2020  10:07                86 .travis.yml
14/10/2020  10:07    <DIR>          bootstrap
14/10/2020  10:07                25 build.cmd
14/10/2020  10:07            28,653 build.xml
14/10/2020  10:07                45 contributors
14/10/2020  10:07    <DIR>          docs
14/10/2020  10:07    <DIR>          examples
14/10/2020  10:07    <DIR>          grammars
14/10/2020  10:07                 0 head
14/10/2020  10:07    <DIR>          lib
14/10/2020  10:07             1,536 LICENSE
14/10/2020  10:07             2,274 makedist
14/10/2020  10:07               551 make_bundle.cmd
14/10/2020  10:07               533 make_bundle.sh
14/10/2020  10:07            22,817 NfaStateTest.java
14/10/2020  10:07            27,177 pom.xml
14/10/2020  10:07            19,317 README.md
14/10/2020  10:07    <DIR>          rulesets
14/10/2020  10:40    <DIR>          scripts
14/10/2020  10:07    <DIR>          src
14/10/2020  10:39    <DIR>          target
14/10/2020  10:07    <DIR>          test
              15 File(s)        104,754 bytes
              13 Dir(s)  553,477,947,392 bytes free
UT7 14-Oct-20 6:33am    
This is the directory when I downloaded it - C:\Users\Babatunde\Downloads\javacc-javacc-7.0.9.zip
But unzipped it and moved it to my target directory - C:\Program Files\Java
And this is the path to the script directory that I added to my system variable path - C:\Program Files\Java\javacc.jar\scripts
Also notice that I have renamed the javacc-7.0.9 to javacc.jar in my target directory and it's still not working. I did all of these before asking the question on code project. Thank you.
Richard MacCutchan 14-Oct-20 7:43am    
So is it working now?
UT7 14-Oct-20 7:52am    
No, it's not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900