【发布时间】:2019-08-19 10:25:43
【问题描述】:
我在 java 方面相对缺乏经验,所以希望我能够在这里提供足够的信息,以便对其他人相关和有用。
我正在尝试运行其他人的代码库,该代码库接受两个输入文件,在通过它们运行代码时将一些信息打印到 STDOUT 并退出。
我使用如下命令编译了代码:
java -g -cp .:../../deps/dep1.jar:../../deps/dep2.jar:../../deps/dep3.jar nameofclass/Nameofclass.java nameofclass/File1.java nameofclass/File2.java nameofclass/File3.java
然后我可以使用jdb 执行如下所示:
jdb -classpath ".:../../deps/dep1.jar:../../deps/dep2.jar:../../deps/dep3.jar:" nameofclass.Nameofclass file1.ext file2.ext
然后在jdb中:
run nameofclass.Nameofclass file1.ext file2.ext
当我这样做时,我会在 jdb 中打印出正确运行代码的进程,并以 The application exited 结束:
Set uncaught java.langh.Throwable
Set deferred uncaught java.langh.Throwable
>
VM Started: /path/to/src
<print out of the code running correctly>
The application exited
到目前为止,一切都很好。当我尝试使用 java 而不是 jdb 运行相同的代码时,我得到:
java -cp ".:../../deps/dep1.jar:../../deps/dep2.jar:../../deps/dep3.jar:" nameofclass.Nameofclass file1.ext file2.ext
Exception in thread "main" java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: java/lang/invoke/StringConcatFactory
跟踪指向 main 函数开头的一行代码,使用jdb 运行似乎没有任何问题。
任何想法如何运行我可以使用jdb 成功运行但只需在命令行上使用java 的代码?
【问题讨论】:
-
StringConcatFactory 是从 Java 9 开始的。也许检查 java 版本(java -version)。
-
java 版本是什么?
-
啊!我懂了。我想我为
jdb安装了openjdk-9 和为java安装了一个较旧的java。我现在更正了以下内容:askubuntu.com/questions/176121/…