[英]JSONobject works in intellij but not when run from command line
I have used maven to install JSON support to my Java project in IntelliJ. 我已经使用maven在IntelliJ中将JSON支持安装到我的Java项目中。 The project runs without problems while using JSONObject when I run it from the IntelliJ console.
从IntelliJ控制台运行该项目时,使用JSONObject时该项目运行不会出现问题。 When I open the IntelliJ terminal and run from the command line I get the following error.
当我打开IntelliJ终端并从命令行运行时,出现以下错误。
I had the exact same issue where everything ran well when executed from IDE (IntelliJ) but throwing same "NoClassDefFound" error when executing jar file in command line. 我遇到了完全相同的问题,即从IDE(IntelliJ)执行时一切运行良好,但是在命令行中执行jar文件时却抛出相同的“ NoClassDefFound”错误。
Assuming you are using Maven, below is the best workaround I found: How to Create an Executable JAR with Maven 假设您正在使用Maven,以下是我发现的最佳解决方法: 如何使用Maven创建可执行的JAR
Henry's answer " You need to add the dependencies to the class path when executing the program. " provide the best clue.
亨利的答案“ 执行程序时需要将依赖项添加到类路径中。 ”提供了最佳线索。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.