我去了Windows -> Preferences -> Java -> install JRE's
并将我的jdk 10
文件放在其中。仍然在那里但未被阅读
我去了computer -> right click properties -> advance systems-> added
JAVA_HOME
systems variables
我还以->运行配置->环境的身份运行,并尝试将Java 10路径放置在其中,但是在运行弹簧批测试时却出现了错误。
我去过几乎所有地方,都尝试着把Java带回家阅读JDK,但它仍然显示为JRE:
Working Directory: C:\Users\git\paymentportalbatchjob
Gradle User Home: C:\Users\.gradle
Gradle Distribution: Local installation at
C:\Users\Software\gradle-4.10.2-bin\gradle-4.10.2
Gradle Version: 4.10.2
-> Java Home: C:\Program Files\Java\jre1.8.0_171 <-
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
Tests: com.ecom.BatchTest
错误:
> Task :bootBuildInfo
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Could not target platform: 'Java SE 10' using tool chain: 'JDK 8 (1.8)'.
编辑:我决定删除Java 1.8,现在将JAVA HOME显示为10,但是它是JRE而不是JDK,我收到一个新错误。 (JRE 0和JDK 10都在同一文件夹中)
Working Directory: C:\Users\git\rxdpf-paymentportalbatchjob
Gradle User Home: C:\Users\.gradle
Gradle Distribution: Local installation at C:\Users\Software\gradle-
4.10.2-bin\gradle-4.10.2
Gradle Version: 4.10.2
Java Home: C:\Program Files\Java\jre-10.0.1
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
Tests: com.ecom.BatchTest#setupMongo
新错误:
> Configure project :
createDockerfile
createDockerfile
> Task :bootBuildInfo
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Cannot find System Java Compiler. Ensure that you have installed a JDK
(not just a JRE) and configured your JAVA_HOME system variable to point to
the according directory.
答案 0 :(得分:0)
想出了一个短期解决方案。 JAVA_HOME仍会恢复为JRE,但是如果您单击
> run as -> run configuration -> gradle project, chose your project ->
> Java home -> add your jdk file and click run.
这对我有用。但是当我要进行gradle测试时,我不得不重复这些步骤
Working Directory: C:\Users\git\rxdpf-paymentportalbatchjob
Gradle User Home: C:\Users\.gradle
Gradle Distribution: Local installation at C:\Users\Software\gradle-4.10.2-bin\gradle-4.10.2
Gradle Version: 4.10.2
Java Home: C:\Program Files\Java\jdk-10.0.1
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
Gradle Tasks: testClasses
> Configure project :
createDockerfile
createDockerfile
> Task :bootBuildInfo
> Task :compileJava UP-TO-DATE
> Task :generateGitProperties UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes
> Task :compileTestJava
> Task :processTestResources NO-SOURCE
> Task :testClasses
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 7s
5 actionable tasks: 2 executed, 3 up-to-date