function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Josip Juric87Josip Juric87 

VS Code with SFDX - ERROR: Java 8 is required to run

After installing VS Code and adding the Salesforce extensions, I get the error: "Java 8 is required to run. Download and install it from https://java.com/en/download/.", although I have Java 9 running. What can I do to fix that?
NagendraNagendra (Salesforce Developers) 
Hi Josip,

Sorry for this issue you are encountering.

May I suggest you please check with the prerequisites below.
Prerequisites
  • Before you set up this extension, make sure that you have these essentials.
  • Java 8 Platform, Standard Edition Development Kit
  • Some features in Salesforce Extensions for VS Code depend upon the Java 8 Platform, Standard Edition Development Kit (JDK).
  • If you don’t already have the JDK installed, install the latest version of the Java 8 JDK from Java SE Development Kit 8 Downloads.
  • Visual Studio Code v1.17 or later
  • Salesforce Extensions for VS Code
  • Code smartness for sObjects in Apex code is powered by the salesforcedx-vscode-core extension. We suggest that you install all extensions in the salesforcedx-vscode extension pack.
  • Its a must that you need to have Java8 platform for this
For more information please check with below link which might help you further. Please let us know if this helps.

Thanks,
Nagendra
Andrea CrucianiAndrea Cruciani
I'm facing the same issue: Java 9 is required for the most recent security requirements in most business workplaces/workstations so the requirement to downgrade to java 8 platform is not acceptable for many developers. Plugin must be updated to work with java 9 platform
 
Ken PennKen Penn
The above link is a 404, does not help. When will more recent versions of Java be enabled?
JPSeaburyJPSeabury
I'm using Java 11, and have not run into any issues although I've only set up my environment this week, and have only done some basic things: create projects, authorize a dev hub on a pre-release Spring'19 instance of SF, create lightning web components, etc. I haven't run into any errors indicating I need to regress back to Java 8.
JPSeaburyJPSeabury
I spoke too soon. Ran into my first issue this AM (using the Create Project with Manifest) command in which VS Code returned an error indicating Java 8 was required to run (I'm running Java 11).  Ugh.

User-added image
Ken Penn 9Ken Penn 9
To use multiple versions of Java on a mac:
1) Download and install Java version 8 from https://java.com/en/download/mac_download.jsp.
2) In the OS terminal, enter command /usr/libexec/java_home -verbose 
3) In the output, take note of the version number for Java 8, e.g. 1.8.0_191
4) In the OS terminal, enter command 
    export JAVA_HOME=`/usr/libexec/java_home -v <version>`
    e.g. export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_191`

To use the other version of Java, repeat steps 2 to 4 with that version.
Jason J AugerJason J Auger
I was also experiencing this issue and have just managed to fix it.  Hopefully this works for you also.
  • Remove all installed versions of the JDK/JRE from your machine (recommend restart afterwards).  Make sure that when typing "/usr/libexec/java_home -verbose" in the terminal, it shows you have 0 (zero) virtual machines installed.  It was showing I had version 10 initially.
  • Download/install the latest JDK (which comes with the JRE).
  • Running "/usr/libexec/java_home -verbose" now shows the following for me:User-added image
  • If you have changed any user settings for your Java path in VS Code, remove and restart VS Code.
Fernando Gonzalez 24Fernando Gonzalez 24
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000g8F3QAI#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=9062I000000g8F3QAI
Sandeep LohaniSandeep Lohani

Well, this is my first post and the following link worked for me to resolve the JAVA required to issue(even though I had java 8 installed).

https://forcedotcom.github.io/salesforcedx-vscode/articles/getting-started/java-setup

 

AdoptOpenJDK
AdoptOpenJDK provides prebuilt OpenJDK binaries for free without authentication or complications.
Navigate to AdoptOpenJDK
Select OpenJDK 11 (LTS)
Select HotSpot
Click the Latest Release button to download.
Once the file is downloaded open it and complete the installation steps.

Joe james 17Joe james 17
I'm utilizing Java 11, and have not run into any issues despite the fact that I've just set up my current circumstance this week, and have just done some essential things: make projects, approve a dev center point on a pre-discharge Spring'19 example of SF, make lightning web segments, and so on I haven't run into any mistakes demonstrating I need to relapse back to Java 8. 
https://designfreedom.design/projects/
Coleman Jones 3Coleman Jones 3
I am currently having similar issue while using Java, kindly please share any relevant solution and provide necessary steps regarding the same. Thanks in advance!

TellDunkin (https://www.telldunkin.me/)
Peter DawsonPeter Dawson

I had this same problem. It took a while to get a solution.

This is how I finally resolved the problem for Windows.

I had multiple version of java installed. I uninstalled them all. Restart the PC.

Visit https://www.oracle.com/uk/java/technologies/javase/jdk11-archive-downloads.html and download the most recent version of Java 11

Get your java filepath. Mine looks like this C:\Program Files\Java\jdk-11.0.14. you only need to go as far as the Jdk-verion folder.

Go to Control Panel and search Environment Variables. Click on Edit the Sytem Environment variables > Environment Variables

In the System variables list. Make sure the JAVA_HOME is the same path ie C:\Program Files\Java\jdk-11.0.14. Click OK.

Now go to VS Code. File>Preferences>Settings ===> Seach apex. Paste the same path "C:\Program Files\Java\jdk-11.0.14" into "Salesforcedx-vscode-apex › Java: Home" text box field.

Restart Vs Code.

I hope this works for you too