Sub topic 1
How VS Code, the Salesforce CLI, Java, and the Extensions Fit Together
Prerequisites
Assume you know basic Visual Studio Code navigation, can run terminal commands, and understand that Apex is Salesforce’s server-side programming language. You also need a Salesforce development org, such as a Developer Edition org or sandbox.
How the Tools Work Together
Visual Studio Code is the editor. The Salesforce CLI (sf) creates projects, authenticates to orgs, deploys source, retrieves changes, and runs tests.
The Salesforce Extension Pack adds Salesforce commands, Apex language support, testing views, and debugging features to VS Code. The Apex language server analyzes Apex in the background. It provides completion, navigation, and diagnostics.
Java is a prerequisite for the Apex language server. It runs in a Java Development Kit (JDK), which is the Java toolset required by development tools.
Installing VS Code
Install Visual Studio Code for your operating system from the official Visual Studio Code website. Start VS Code once, then confirm that its integrated terminal opens and can run commands.
Installing and Verifying the Salesforce CLI
Install Salesforce CLI, then verify that the sf command is available:
code --version
sf --version
java -versionThe first command checks VS Code’s command-line launcher. The second checks Salesforce CLI. The third checks Java. If a command is not found, install that tool or add its installation directory to your PATH, the list of directories searched by your shell.
Installing a Java JDK
Install a supported JDK, not only a Java runtime. If the extensions cannot locate it automatically, set its location in VS Code’s settings.json:
{
"salesforcedx-vscode-apex.java.home": "/path/to/your/jdk"
}Use the actual JDK directory for your operating system. Restart VS Code after changing this setting.
Installing the Salesforce Extension Pack
Open Extensions in VS Code, search for Salesforce Extension Pack, and install the pack published by Salesforce. It includes the Apex extension and related Salesforce tooling. Open a Salesforce project before using Apex completion or Salesforce commands.
Exercise
Which tool runs the Apex language server, and which tool connects the project to an org?
Show answer
The Java JDK runs the Apex language server. The Salesforce CLI connects the project to an org.