javac -cp $CLASSPATH Xi*.java maybe ? Raphael
----- Mail original ----- De: "Sam Kuper" <sampabloku...@posteo.net> À: "ML debian-java" <debian-java@lists.debian.org> Envoyé: Jeudi 9 Juillet 2020 02:19:10 Objet: javac - error: package org.antlr.v4.runtime does not exist Dear all, I apologise in advance for asking what might be an ignorant question, but it has been ages since I used Java for anything and so my Java troubleshooting skills are currently rusty/nonexistent. On a box running Debian Stretch (oldstable), I am trying to compile an Antlr4 lexer & parser. The first step (generating the lexer & parser .java files from .g4 files) works fine, but the second step (compiling the the lexer & parser) does not. Here's the first step: $ mkdir /tmp/antlr-test $ cd $_ $ wget --page-requisites --recursive --level=inf --convert-links \ --no-parent \ https://www.cs.cornell.edu/courses/cs4120/2013fa/handouts/antlr.html $ cd www.cs.cornell.edu/courses/cs4120/2013fa/handouts/xi $ ls -1 hello.xi XiLexer.g4 XiParser.g4 $ antlr4 XiLexer.g4 XiParser.g4 -no-listener ; echo $? 0 $ ls -1 hello.xi XiLexer.g4 XiLexer.java XiLexer.tokens XiParser.g4 XiParser.java XiParser.tokens All fine so far, as you can see. Now the second step: $ javac Xi*.java XiLexer.java:2: error: package org.antlr.v4.runtime does not exist import org.antlr.v4.runtime.Lexer; ^ [SNIP - for full output, see attached file.] 100 errors Oh dear. What to do? The [Antlr4 FAQ](https://github.com/antlr/antlr4/blob/master/doc/faq/installation.md_ says, "If you see these kinds of errors, it's because you don't have the runtime or complete ANTLR library in your CLASSPATH." I installed Antlr4 via `sudo apt install antlr4` and I installed javac via `sudo apt install default-jdk` so I would hope that Antlr4 is reachable by javac, but in case not, I tried manually populating the CLASSPATH environment variable with the same contents found in the antlr4 executable, before running javac again: $ cat /usr/bin/antlr4 #!/bin/sh CLASSPATH=/usr/share/java/stringtemplate4.jar:/usr/share/java/antlr4.jar:/usr/share/java/antlr4-runtime.jar:/usr/share/java/antlr3-runtime.jar/:/usr/share/java/treelayout.jar exec java -cp $CLASSPATH org.antlr.v4.Tool "$@" $ CLASSPATH='.' $ CLASSPATH+=':/usr/share/java/stringtemplate4.jar' $ CLASSPATH+=':/usr/share/java/antlr4.jar' $ CLASSPATH+=':/usr/share/java/antlr4-runtime.jar' $ CLASSPATH+=':/usr/share/java/antlr3-runtime.jar/' $ CLASSPATH+=':/usr/share/java/treelayout.jar"; javac Xi*.java XiLexer.java:2: error: package org.antlr.v4.runtime does not exist import org.antlr.v4.runtime.Lexer; ^ [SNIP - for full output, see attached file.] 100 errors No improvement :( So my question is: how can I make the `javac Xi*.java` command succeed, *without* having to fall back on a non-Debian-provided Antlr4 installation? (Two examples of non-Debian-provided Antlr4 installation would be: a .jar produced by me cloning and building https://github.com/antlr/antlr4; or if I downloaded this .jar: https://www.antlr.org/download/antlr-4.7.1-complete.jar ). Thanks in advance for any help you can provide! Sam -- A: When it messes up the order in which people normally read text. Q: When is top-posting a bad thing? () ASCII ribbon campaign. Please avoid HTML emails & proprietary /\ file formats. (Why? See e.g. https://v.gd/jrmGbS ). Thank you.