[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: javac unaware of Antlr4 (was: Re: javac - error: package org.antlr.v4.runtime does not exist)



Sam,

No, it is not supposed to set the classpath. This is a limitation of the Linux-Java integration. The main problem I think is that in Java you rarely depend on every library available at the same time. You want to partition things to avoid collisions. I agree that it would be better if it worked as in the C/C++ world, that is, you install a library and it is made available automatically in the LD_LIBRARY_PATH. As a matter of fact, I have developed my own Java desktop environment, just to be able to solve this problem. The idea is that everything runs in a single JVM. I am using maven central as software package repository/market. So, it operates sort of like Android, but with the standard JDK. Here it is if you are interested:

https://github.com/rjolly/linoleum

Raphael

----- Mail original -----
De: "Sam Kuper" <sampablokuper@posteo.net>
À: "ML debian-java" <debian-java@lists.debian.org>
Envoyé: Jeudi 9 Juillet 2020 12:32:31
Objet: javac unaware of Antlr4 (was: Re: javac - error: package org.antlr.v4.runtime does not exist)

On Thu, Jul 09, 2020 at 10:43:46AM +0200, raphael.jolly@free.fr wrote:
> 9 Juillet 2020 02:19:10, Sam Kuper wrote:
>> 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.  [..]
>>
>>     $ 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. [..]
>> 
>> 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: [..]
>> 
>>     $ 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?
>
> javac -cp $CLASSPATH Xi*.java maybe ?

Ah, yes.  Thank you!  The following worked:

     $ 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 -cp "$CLASSPATH" Xi*.java

This raises a question, though.

Since javac and Antlr4 were both installed via apt (see above), why was
it necessary for me to manually set the CLASSPATH in order for javac to
be able to find Antlr4's jars?  I.e. shouldn't apt (or the packages
installed by apt) have configured things, during installation, so that
such manual intervention would be unnecessary?

If it should have done that, should I file a bug report?

Thanks again,

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.


Reply to: