[英]Gradle error with jar file on command line
This is my first time working with gradle so please be patient.这是我第一次使用 gradle,所以请耐心等待。 I am building a java project and trying to build and compile it with gradle. The code works just fine on an IDE.
我正在构建一个 java 项目并尝试使用 gradle 构建和编译它。该代码在 IDE 上运行良好。
I am running into an error on the command line with I run the command below:我运行以下命令时在命令行上遇到错误:
java -jar build\libs\*****.jar
the project builds just fine with:该项目构建得很好:
gradlew build
The error I am getting is:我得到的错误是:
Exception in thread "main" java.lang.NullPointerException: source
at java.base/java.util.Objects.requireNonNull(Objects.java:233)
at java.base/java.util.Scanner.<init>(Scanner.java:595)
at java.base/java.util.Scanner.<init>(Scanner.java:581)
at com.***.MortgagePlan.handleData(MortgagePlan.java:20)
at com.***.MortgagePlan.main(MortgagePlan.java:10)
I am wondering how to fix this error.我想知道如何解决这个错误。 I have a main class, a customer class along with a text data file in one folder.
我有一个主 class,一个客户 class 以及一个文件夹中的文本数据文件。 The build.gradle looks like this:
build.gradle 看起来像这样:
plugins{
id 'java'
}
jar{
manifest {
attributes 'Main-Class': 'com.***.MortgagePlan'
}
}
My code requires me to import the scanner, input stream and an arraylist. Any ideas?我的代码要求我导入扫描仪,输入 stream 和一个 arraylist。有什么想法吗?
ps.附言。 the * are not the actual names of my files/ directories.
* 不是我的文件/目录的实际名称。 I have blocked out sensitive information
我屏蔽了敏感信息
You might want to check if your build system and/or IDE is running on the same JVM version as the java command.您可能想检查您的构建系统和/或 IDE 是否运行在与 java 命令相同的 JVM 版本上。 If those are mismatched, certain features may work in the IDE but not in deployment.
如果这些不匹配,某些功能可能在 IDE 中工作,但在部署中不工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.