0
votes

I am trying to execute a test inside a gradle project.But when Itry to execute the tests using 'gradle test' in Intellij it fails .

what I have tried

  1. create and build the project without error using 'gradle clean build'

  2. open run configuration in intellij , select gradle , and create and execution with gradle task 'test'

  3. execute newly created gradle run configuration

what I observe

  1. gradle fails at task 'test' with error 'Error: Could not create the Java Virtual Machine.'

  2. also gradle run never stops until I forcefully stop it

  3. also it keep printing ' gradle executor 1(,2,3 and so on) executing , failed '

I am using java 9 , intellij , gradle .

1

1 Answers

1
votes

I am running Kotlin project with gradle in IntelliJ.

------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------

Build time:   2019-02-08 19:00:10 UTC
Revision:     f02764e074c32ee8851a4e1877dd1fea8ffb7183

Kotlin DSL:   1.1.3
Kotlin:       1.3.20
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          11.0.2 (Amazon.com Inc. 11.0.2+9-LTS)
OS:           Mac OS X 10.14.3 x86_64

Getting similar issue, but to be specific:

Task :run FAILED
Unrecognized option: -d64 
Error: Could not create the Java Virtual Machine.
...

To solve my issue, I basically had to select correct JDK for my IntelliJ.

To switch the Java runtime used to run IntelliJ IDEA:

On the Help menu, click Find Action, or press ⇧⌘A.

Find and select the Switch Boot JDK action.

Select the desired JDK and click OK.

Found this resource that helps! https://www.jetbrains.com/help/idea/tuning-the-ide.html

If by any chance you select a wrong JDK version, and the IDE not starting anymore, delete idea.jdk file: https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under?page=3