Linux系统上的类Path错误,如果从Windows访问目录,则可以使用
我正在使用JFLEX和Javacup在Java建造解析器。我将Windows Development Box上的所有必要的JAR文件复制到Linux框中,但无法正常工作。该命令
java -cp jflex.jar:java-cup-11a.jar:myparser.jar main.Parser
给了我“错误:找不到或加载main类main.parser。”
我检查了jar文件:myparser.jar肯定包含main/parser.class,而其他任何地方都没有。然后,我尝试更改class路径中的jar文件的顺序:
java -cp myparser.jar:jflex.jar:java-cup-11a.jar main.Parser
这次,它给了我不同的错误:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: java_cup/runtime/Scanner
最后,我使用samba使Linux目录可以从Windows框中访问,并输入了此信息:
java -cp jflex.jar;java-cup-11a.jar;myparser.jar main.Parser
与第一个相同一个除了“;”作为分离器而不是“:”。它正如预期的,没有错误。
我认为这可能是一个版本的问题(“写一次,在任何地方运行……也许”)。当我做“ Java -version”时,我的Windows机器对此表示:
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)
我的Linux框说:
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
所以我很难相信这是一个版本的问题。
有谁知道会导致这件事是什么?
I am building a parser in Java using JFlex and JavaCUP. I copied all the necessary jar files across from my Windows development box to a Linux box, and couldn't get it to work. The command
java -cp jflex.jar:java-cup-11a.jar:myparser.jar main.Parser
gave me "Error: could not find or load main class main.Parser."
I checked the jar files: myparser.jar definitely contains main/Parser.class, and there isn't one anywhere else. Then I tried changing the order of the jar files in the classpath:
java -cp myparser.jar:jflex.jar:java-cup-11a.jar main.Parser
This time, it gave me a different error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: java_cup/runtime/Scanner
Finally I used Samba to make the Linux directory accessible from the Windows box, and typed this:
java -cp jflex.jar;java-cup-11a.jar;myparser.jar main.Parser
This is the same as the first one except with ";" as separators instead of ":". It worked as expected, with no errors.
I thought that it might be a versioning issue ("write once, run anywhere... maybe"). When I do "java -version" my Windows machine says this:
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)
My Linux box says this:
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
So I find it hard to believe it's a versioning issue.
Does anyone have any idea what might be causing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论