简体   繁体   English

类路径顺序更改时无法启动 main class

[英]Can't start main class when classpath order changes

I am trying to start rascal with clair from the command line, however I do not understand why this happens:我试图从命令行用 clair 启动 rascal,但我不明白为什么会这样:

java -cp "rascal-0.18.0.jar;clair_0.1.0.202005281059.jar;org.eclipse.cdt.core_6.11.0.202003081657.jar" org.rascalmpl.shell.RascalShell
Version: 0.18.0
INFO: detected |lib://rascal| at |jar+file:///C:/ws/rascal-0.18.0.jar!/|
INFO: detected |lib://clair| at |jar+file:///C:/ws/clair_0.1.0.202005281059.jar!/|
rascal>

But when the order of the jars changes, it fails:但是当 jars 的顺序改变时,它失败了:

java -cp "clair_0.1.0.202005281059.jar;rascal-0.18.0.jar;org.eclipse.cdt.core_6.11.0.202003081657.jar" org.rascalmpl.shell.RascalShell
Version: 0.18.0
INFO: detected |lib://clair| at |jar+file:///C:/ws/clair_0.1.0.202005281059.jar!/|
INFO: detected |lib://rascal| at |jar+file:///C:/ws/rascal-0.18.0.jar!/|
main function should either have one argument of type list[str], or keyword parameters
Usage: java -jar ...

Is this normal behavior with classpaths?这是类路径的正常行为吗?

Note: The clair jar does not contain a org.rascalmpl.shell.RascalShell class.注意:clair jar 不包含 org.rascalmpl.shell.RascalShell class。

Update: Removing from META-INF/RASCAL.MF the line:更新:从 META-INF/RASCAL.MF 中删除以下行:

Main-Function: main
Main-Module: lang::cpp::IDE

resolves the problem, so it seems to be an issue with Rascal (and a rascal function) and not with Java (and a Java function).解决了问题,所以这似乎是 Rascal(和 rascal 函数)的问题,而不是 Java(和 Java 函数)的问题。

I think you have found two bugs in the REPL:我认为您在 REPL 中发现了两个错误:

  1. The second behavior is the bug that we try to run the Main-Function definition which is intended for the IDE plugin, also in the terminal.第二个行为是我们尝试运行Main-Function定义的错误,该定义适用于 IDE 插件,也在终端中。 I think the issue/bug is that we use the same configuration for command line as ide integration point, we might need to add a seperate tag for this.我认为问题/错误是我们使用与 ide 集成点相同的命令行配置,我们可能需要为此添加一个单独的标记。
  2. We should provide a way to say which RASCAL.MF we want to run, since now it just picks the first one it sees (rascal also has a RASCAL.MF file).我们应该提供一种方法来说明我们要运行哪个 RASCAL.MF,因为现在它只选择它看到的第一个(rascal 也有一个 RASCAL.MF 文件)。

RascalShell's main function behaves differently if there are commandline parameters and differently depending on the first RASCAL.MF file it finds in the classpath.如果有命令行参数,RascalShell 的主要 function 行为会有所不同,并且会有所不同,具体取决于它在类路径中找到的第一个 RASCAL.MF 文件。

  • If there is a parameter, then it loads that parameter as a module name and invokes the main function in that module, passing it the other commandline parameters如果有一个参数,那么它加载该参数作为模块名称并调用该模块中的主要 function,将其他命令行参数传递给它
  • Otherwise it starts the REPL否则它启动 REPL
  • But : if the first RASCAL.MF file it finds in the classpath has a Main-Module and a Main-Function, then it loads this module always and starts its main function.但是:如果它在类路径中找到的第一个 RASCAL.MF 文件有一个 Main-Module 和一个 Main-Function,那么它总是加载这个模块并启动它的主 function。

I suspect the latter is at work: the order of the classpath changes which RASCAL.MF file is found and therefore the REPL does not start but some module is being loaded and not found.我怀疑后者在起作用:类路径的顺序改变了找到的 RASCAL.MF 文件,因此 REPL 没有启动,但一些模块正在加载但找不到。 I'm not sure though, since I can't set a breakpoint from here;-)不过我不确定,因为我不能从这里设置断点;-)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jar 可执行文件,但找不到主 class 的类路径 - Jar executable but can not find the classpath for main class 我在JADE Main Container GUI中的CLASSPATH中找不到代理类 - I can't find my agent class from the CLASSPATH in the JADE Main Container GUI 通过java -classpath xxx -jar jarfile调用时找不到依赖类,但是可以通过java -classpath xx class找到 - Dependent class can't be found when invoke by java -classpath xxx -jar jarfile, but can be found by java -classpath xx class 错误:尝试运行JAR时无法找到或加载主类Main。 Manifest和classpath看起来很好,仍然无法正常工作? - Error: Could not find or load main class Main when trying to run JAR. Manifest and classpath look fine, still doesn't work? Spring 无法在类路径中找到 *is* 的驱动程序类 - Spring can't locate a driver class that *is* in the classpath Java类路径在多个罐子时丢失主类 - Java classpath losing Main Class when multiple jar 从Gradle执行Java类时找不到Main - Can't find Main when executing a Java class from Gradle Javac找不到.class文件,具有正确的类路径 - Javac can't find .class files, have right classpath 当我在Main类中使用abstract或interface时,在运行时向类路径添加类时出现NoClassDefFoundError - NoClassDefFoundError when adding classes to the classpath at runtime when I used abstract or interface in Main class 无法在 IntelliJ 中选择类作为主类 - Can't choose class as main class in IntelliJ
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM