Issue
I am running current setup:
- OS: Win10
- Java: 1.8 AdoptOpenJDK (JDK + JRE)
- Mule: 4.2.1 / Anypoint Studio 7.9
- Maven: embedded in Studio - 3.6.3
The issue is:
Unable to execute Java command. The system cannot find the file specified. (0x2)
"C:\\Program Files\\AdoptOpenJDK\\jdk-8.0.282.8-hotspot\\bin\\bin\\javaw.exe" -version
Failed to retrieve the version of Java. Resolving to the lowest supported version (1.4).
Launching a JVM...
Unable to execute Java command. The system cannot find the file specified. (0x2)
"C:\\Program Files\\AdoptOpenJDK\\jdk-8.0.282.8-hotspot\\bin\\bin\\javaw.exe"
Win10 environments:
C:\Users\1>echo %JAVA_HOME% - C:\Program Files\AdoptOpenJDK\jdk-8.0.282.8-hotspot
C:\Users\1>echo %PATH% - C:\Program Files\AdoptOpenJDK\jdk-8.0.282.8-hotspot\bin;C:\apache-maven-3.8.1-bin\apache-maven-3.8.1\bin;
That is a tip from Studio project run below the issue description:
Advice:
Usually when the Wrapper fails to start the JVM process, it is
because of a problem with the value of the configured Java command.
Currently:
wrapper.java.command=C:\\Program Files\\AdoptOpenJDK\\jdk-8.0.282.8-hotspot\\bin\\bin\\javaw.exe
Please make sure that the PATH or any other referenced environment
variables are correctly defined for the current environment.
But it tells me nothing except system env vars but they look correct.
What I have tried:
- Checking environment variables (system and user) - everything is fine, also checked with a teammate to be sure
- Anypoint Studio checks: runs correct (1.8) Java, Maven (3.6.3) and Mule (4.2.1)
- Maven and Studio config files - everything is also correct (uses %JAVA_HOME%)
I have no idea where is Studio taking this second "bin" from, thank you for all advices.
Solution
By default Anypoint Studio has its embedded version of OpenJDK to execute Mule projects. You can select an alternative one from the UI in Preferences / Java / Installed JREs (serves for both JDKs and JREs). It seems that this is the case because the error refers to a JDK installed outside Studio. Ensure that the location of the Java 8 SDKs configured point to the 'home' directory of the JDK (in your case it seems to be C:\Program Files\AdoptOpenJDK\jdk-8.0.282.8-hotspot) rather than to the bin subdirectory (C:\Program Files\AdoptOpenJDK\jdk-8.0.282.8-hotspot\bin). Studio will assume the Java executable is under the bin subdirectory of the JDK home.
Answered By - aled
Answer Checked By - Senaida (JavaFixing Volunteer)