通过Ubuntu终端进行编译在Windows 10上

如何解决通过Ubuntu终端进行编译在Windows 10上

我正在上一门有关编译器技术的课程。我已经创建了一个g4格式的文件,当我尝试使用java编译器(javac)进行编译时会对其进行编译,那么它会给我带来很多错误。

有人可以解释我在做什么错吗?

下面,我将显示我正在输入的内容以及我做错了什么。 我尝试检查是否没有安装antlr4,但是我已经安装了,并且我确定已经安装了。 是否通过Microsoft Store通过Ubuntu应用程序进行了每次安装,而我正在Windows 10上使用Ubuntu终端。

:~$ cd /mnt/c/Users/myUser/dato
:/mnt/c/Users/myUser/dato$ antlr4 dato.g4
:/mnt/c/Users/myUser/dato$ javac *.java
datoBaseListener.java:3: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.ParserRuleContext;
                           ^
datoBaseListener.java:4: error: package org.antlr.v4.runtime.tree does not exist
import org.antlr.v4.runtime.tree.ErrorNode;
                                ^
datoBaseListener.java:5: error: package org.antlr.v4.runtime.tree does not exist
import org.antlr.v4.runtime.tree.TerminalNode;
                                ^
datoListener.java:2: error: package org.antlr.v4.runtime.tree does not exist
import org.antlr.v4.runtime.tree.ParseTreeListener;
                                ^
datoListener.java:8: error: cannot find symbol
public interface datoListener extends ParseTreeListener {
                                      ^
  symbol: class ParseTreeListener
datoParser.java:3: error: package org.antlr.v4.runtime.dfa does not exist
import org.antlr.v4.runtime.dfa.DFA;
                               ^
datoParser.java:12: error: cannot find symbol
public class datoParser extends Parser {
                                ^
  symbol: class Parser
datoParser.java:92: error: cannot find symbol
        public static class StartContext extends ParserRuleContext {
                                                 ^
  symbol:   class ParserRuleContext
  location: class datoParser
datoBaseListener.java:31: error: cannot find symbol
        @Override public void enterEveryRule(ParserRuleContext ctx) { }
                                             ^
  symbol:   class ParserRuleContext
  location: class datoBaseListener
datoBaseListener.java:37: error: cannot find symbol
        @Override public void exitEveryRule(ParserRuleContext ctx) { }
                                            ^
  symbol:   class ParserRuleContext
  location: class datoBaseListener
datoBaseListener.java:43: error: cannot find symbol
        @Override public void visitTerminal(TerminalNode node) { }
                                            ^
  symbol:   class TerminalNode
  location: class datoBaseListener
datoBaseListener.java:49: error: cannot find symbol
        @Override public void visitErrorNode(ErrorNode node) { }
                                             ^
  symbol:   class ErrorNode
  location: class datoBaseListener
datoParser.java:93: error: cannot find symbol
                public Token d;
                       ^
  symbol:   class Token
  location: class StartContext
datoParser.java:94: error: cannot find symbol
                public TerminalNode EOF() { return getToken(datoParser.EOF,0); }
                       ^
  symbol:   class TerminalNode
  location: class StartContext
datoParser.java:95: error: cannot find symbol
                public TerminalNode MYTOKEN() { return getToken(datoParser.MYTOKEN,0); }
                       ^
  symbol:   class TerminalNode
  location: class StartContext
datoParser.java:96: error: cannot find symbol
                public StartContext(ParserRuleContext parent,int invokingState) {
                                    ^
  symbol:   class ParserRuleContext
  location: class StartContext
datoParser.java:101: error: cannot find symbol
                public void enterRule(ParseTreeListener listener) {
                                      ^
  symbol:   class ParseTreeListener
  location: class StartContext
datoParser.java:105: error: cannot find symbol
                public void exitRule(ParseTreeListener listener) {
                                     ^
  symbol:   class ParseTreeListener
  location: class StartContext
datoParser.java:15: error: cannot find symbol
        protected static final DFA[] _decisionToDFA;
                               ^
  symbol:   class DFA
  location: class datoParser
datoParser.java:16: error: cannot find symbol
        protected static final PredictionContextCache _sharedContextCache =
                               ^
  symbol:   class PredictionContextCache
  location: class datoParser
datoParser.java:43: error: cannot find symbol
        public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES,_SYMBOLIC_NAMES);
                            ^
  symbol:   class Vocabulary
  location: class datoParser
datoParser.java:72: error: cannot find symbol
        public Vocabulary getVocabulary() {
               ^
  symbol:   class Vocabulary
  location: class datoParser
datoParser.java:86: error: cannot find symbol
        public ATN getATN() { return _ATN; }
               ^
  symbol:   class ATN
  location: class datoParser
datoParser.java:88: error: cannot find symbol
        public datoParser(TokenStream input) {
                          ^
  symbol:   class TokenStream
  location: class datoParser
datoParser.java:110: error: cannot find symbol
        public final StartContext start() throws RecognitionException {
                                                 ^
  symbol:   class RecognitionException
  location: class datoParser
datoParser.java:137: error: cannot find symbol
        public static final ATN _ATN =
                            ^
  symbol:   class ATN
  location: class datoParser
datoParser.java:2: error: package org.antlr.v4.runtime.atn does not exist
import org.antlr.v4.runtime.atn.*;
^
datoParser.java:4: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.*;
^
datoParser.java:5: error: package org.antlr.v4.runtime.misc does not exist
import org.antlr.v4.runtime.misc.*;
^
datoParser.java:6: error: package org.antlr.v4.runtime.tree does not exist
import org.antlr.v4.runtime.tree.*;
^
datoLexer.java:2: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.Lexer;
                           ^
datoLexer.java:3: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.CharStream;
                           ^
datoLexer.java:4: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.Token;
                           ^
datoLexer.java:5: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.TokenStream;
                           ^
datoLexer.java:8: error: package org.antlr.v4.runtime.dfa does not exist
import org.antlr.v4.runtime.dfa.DFA;
                               ^
datoLexer.java:12: error: cannot find symbol
public class datoLexer extends Lexer {
                               ^
  symbol: class Lexer
datoLexer.java:15: error: cannot find symbol
        protected static final DFA[] _decisionToDFA;
                               ^
  symbol:   class DFA
  location: class datoLexer
datoLexer.java:16: error: cannot find symbol
        protected static final PredictionContextCache _sharedContextCache =
                               ^
  symbol:   class PredictionContextCache
  location: class datoLexer
datoLexer.java:50: error: cannot find symbol
        public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES,_SYMBOLIC_NAMES);
                            ^
  symbol:   class Vocabulary
  location: class datoLexer
datoLexer.java:79: error: cannot find symbol
        public Vocabulary getVocabulary() {
               ^
  symbol:   class Vocabulary
  location: class datoLexer
datoLexer.java:84: error: cannot find symbol
        public datoLexer(CharStream input) {
                         ^
  symbol:   class CharStream
  location: class datoLexer
datoLexer.java:105: error: cannot find symbol
        public ATN getATN() { return _ATN; }
               ^
  symbol:   class ATN
  location: class datoLexer
datoLexer.java:136: error: cannot find symbol
        public static final ATN _ATN =
                            ^
  symbol:   class ATN
  location: class datoLexer
datoLexer.java:6: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.*;
^
datoLexer.java:7: error: package org.antlr.v4.runtime.atn does not exist
import org.antlr.v4.runtime.atn.*;
^
datoLexer.java:9: error: package org.antlr.v4.runtime.misc does not exist
import org.antlr.v4.runtime.misc.*;
^
datoBaseListener.java:31: error: method does not override or implement a method from a supertype
        @Override public void enterEveryRule(ParserRuleContext ctx) { }
        ^
datoBaseListener.java:37: error: method does not override or implement a method from a supertype
        @Override public void exitEveryRule(ParserRuleContext ctx) { }
        ^
datoBaseListener.java:43: error: method does not override or implement a method from a supertype
        @Override public void visitTerminal(TerminalNode node) { }
        ^
datoBaseListener.java:49: error: method does not override or implement a method from a supertype
        @Override public void visitErrorNode(ErrorNode node) { }
        ^
datoParser.java:13: error: cannot find symbol
        static { RuntimeMetaData.checkVersion("4.7.2",RuntimeMetaData.VERSION); }
                                                       ^
  symbol:   variable RuntimeMetaData
  location: class datoParser
datoParser.java:13: error: cannot find symbol
        static { RuntimeMetaData.checkVersion("4.7.2",RuntimeMetaData.VERSION); }
                 ^
  symbol:   variable RuntimeMetaData
  location: class datoParser
datoParser.java:17: error: cannot find symbol
                new PredictionContextCache();
                    ^
  symbol:   class PredictionContextCache
  location: class datoParser
datoParser.java:43: error: cannot find symbol
        public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES,_SYMBOLIC_NAMES);
                                                        ^
  symbol:   class VocabularyImpl
  location: class datoParser
datoParser.java:64: error: method does not override or implement a method from a supertype
        @Override
        ^
datoParser.java:70: error: method does not override or implement a method from a supertype
        @Override
        ^
datoParser.java:76: error: method does not override or implement a method from a supertype
        @Override
        ^
datoParser.java:79: error: method does not override or implement a method from a supertype
        @Override
        ^
datoParser.java:82: error: method does not override or implement a method from a supertype
        @Override
        ^
datoParser.java:85: error: method does not override or implement a method from a supertype
        @Override
        ^
datoParser.java:90: error: cannot find symbol
                _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
                ^
  symbol:   variable _interp
  location: class datoParser
datoParser.java:90: error: cannot find symbol
                _interp = new ParserATNSimulator(this,_sharedContextCache);
                              ^
  symbol:   class ParserATNSimulator
  location: class datoParser
datoParser.java:94: error: cannot find symbol
                public TerminalNode EOF() { return getToken(datoParser.EOF,0); }
                                                                      ^
  symbol:   variable EOF
  location: class datoParser
datoParser.java:95: error: cannot find symbol
                public TerminalNode MYTOKEN() { return getToken(datoParser.MYTOKEN,0); }
                                                       ^
  symbol:   method getToken(int,int)
  location: class StartContext
datoParser.java:99: error: method does not override or implement a method from a supertype
                @Override public int getRuleIndex() { return RULE_start; }
                ^
datoParser.java:100: error: method does not override or implement a method from a supertype
                @Override
                ^
datoParser.java:104: error: method does not override or implement a method from a supertype
                @Override
                ^
datoParser.java:111: error: cannot find symbol
                StartContext _localctx = new StartContext(_ctx,getState());
                                                          ^
  symbol:   variable _ctx
  location: class datoParser
datoParser.java:111: error: cannot find symbol
                StartContext _localctx = new StartContext(_ctx,getState());
                                                                ^
  symbol:   method getState()
  location: class datoParser
datoParser.java:112: error: cannot find symbol
                enterRule(_localctx,RULE_start);
                ^
  symbol:   method enterRule(StartContext,int,int)
  location: class datoParser
datoParser.java:114: error: cannot find symbol
                        enterOuterAlt(_localctx,1);
                        ^
  symbol:   method enterOuterAlt(StartContext,int)
  location: class datoParser
datoParser.java:116: error: cannot find symbol
                        setState(2);
                        ^
  symbol:   method setState(int)
  location: class datoParser
datoParser.java:117: error: cannot find symbol
                        ((StartContext)_localctx).d = match(MYTOKEN);
                                                      ^
  symbol:   method match(int)
  location: class datoParser
datoParser.java:118: error: cannot find symbol
                        setState(3);
                        ^
  symbol:   method setState(int)
  location: class datoParser
datoParser.java:119: error: cannot find symbol
                        match(EOF);
                              ^
  symbol:   variable EOF
  location: class datoParser
datoParser.java:122: error: cannot find symbol
                catch (RecognitionException re) {
                       ^
  symbol:   class RecognitionException
  location: class datoParser
datoParser.java:123: error: cannot find symbol
                        _localctx.exception = re;
                                 ^
  symbol:   variable exception
  location: variable _localctx of type StartContext
datoParser.java:124: error: cannot find symbol
                        _errHandler.reportError(this,re);
                        ^
  symbol:   variable _errHandler
  location: class datoParser
datoParser.java:125: error: cannot find symbol
                        _errHandler.recover(this,re);
                        ^
  symbol:   variable _errHandler
  location: class datoParser
datoParser.java:128: error: cannot find symbol
                        exitRule();
                        ^
  symbol:   method exitRule()
  location: class datoParser
datoParser.java:138: error: cannot find symbol
                new ATNDeserializer().deserialize(_serializedATN.toCharArray());
                    ^
  symbol:   class ATNDeserializer
  location: class datoParser
datoParser.java:140: error: cannot find symbol
                _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
                                     ^
  symbol:   class DFA
  location: class datoParser
datoParser.java:142: error: cannot find symbol
                        _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i),i);
                                                ^
  symbol:   class DFA
  location: class datoParser
datoLexer.java:13: error: cannot find symbol
        static { RuntimeMetaData.checkVersion("4.7.2",RuntimeMetaData.VERSION); }
                                                       ^
  symbol:   variable RuntimeMetaData
  location: class datoLexer
datoLexer.java:13: error: cannot find symbol
        static { RuntimeMetaData.checkVersion("4.7.2",RuntimeMetaData.VERSION); }
                 ^
  symbol:   variable RuntimeMetaData
  location: class datoLexer
datoLexer.java:17: error: cannot find symbol
                new PredictionContextCache();
                    ^
  symbol:   class PredictionContextCache
  location: class datoLexer
datoLexer.java:50: error: cannot find symbol
        public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES,_SYMBOLIC_NAMES);
                                                        ^
  symbol:   class VocabularyImpl
  location: class datoLexer
datoLexer.java:71: error: method does not override or implement a method from a supertype
        @Override
        ^
datoLexer.java:77: error: method does not override or implement a method from a supertype
        @Override
        ^
datoLexer.java:86: error: cannot find symbol
                _interp = new LexerATNSimulator(this,_sharedContextCache);
                ^
  symbol:   variable _interp
  location: class datoLexer
datoLexer.java:86: error: cannot find symbol
                _interp = new LexerATNSimulator(this,_sharedContextCache);
                              ^
  symbol:   class LexerATNSimulator
  location: class datoLexer
datoLexer.java:89: error: method does not override or implement a method from a supertype
        @Override
        ^
datoLexer.java:92: error: method does not override or implement a method from a supertype
        @Override
        ^
datoLexer.java:95: error: method does not override or implement a method from a supertype
        @Override
        ^
datoLexer.java:98: error: method does not override or implement a method from a supertype
        @Override
        ^
datoLexer.java:101: error: method does not override or implement a method from a supertype
        @Override
        ^
datoLexer.java:104: error: method does not override or implement a method from a supertype
        @Override
        ^
datoLexer.java:137: error: cannot find symbol
                new ATNDeserializer().deserialize(_serializedATN.toCharArray());
                    ^
  symbol:   class ATNDeserializer
  location: class datoLexer
datoLexer.java:139: error: cannot find symbol
                _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
                                     ^
  symbol:   class DFA
  location: class datoLexer
datoLexer.java:141: error: cannot find symbol
                        _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i),i);
                                                ^
  symbol:   class DFA
  location: class datoLexer
100 errors
:/mnt/c/Users/myUser/dato$ sudo apt install antlr4
[sudo] password for ACCOUNT:
Reading package lists... Done
Building dependency tree
Reading state information... Done
antlr4 is already the newest version.
0 upgraded,0 newly installed,0 to remove and 2 not upgraded.
:/mnt/c/Users/myUser/dato$

为什么会出现这些错误?我使用了错误的命令吗?

解决方法

Java编译器找不到ANTLR运行时类(这是error: package org.antlr.v4.runtime does not exist错误的含义)。换句话说,antlr-4.8-complete.jar are not properly added to your CLASSPATH中的类。

忘记这些命令的任何别名:了解如何自己编译Java类。

首先确保文件antlr-4.8-complete.jardato.g4位于同一文件夹中,然后在该文件夹中打开终端和CD。

1生成解析器

java -cp antlr-4.8-complete.jar org.antlr.v4.Tool dato.g4

2个编译Java文件

视窗
javac -cp .;antlr-4.8-complete.jar *.java
*尼克斯
javac -cp .:antlr-4.8-complete.jar *.java

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-