forcedotcom/sfdx-code-analyzer-vscode

[BUG]

Closed this issue · 7 comments

Describe the bug
Our company does now allow the use of Java or JRE from Oracle. We use Zulu JDK 17.

To Reproduce
Steps to reproduce the behavior:
Remove all Java from the computer.
Installed Zulu JDK 17 with FULL Install and PATH Updates.
Reboot
Configure VS code with Java_Home as null.
Configure VSCode with javaHome variable as statred in the Error.
Write some code.
Try to use the Salesforce Apex Analyzer.

Expected behavior
Not sure, it's never worked.

Screenshots
image

Desktop (please complete the following information):

  • OS: [e.g. iOS]
    Windows 10
  • Browser [e.g. chrome, safari]
    Edge
  • Version [e.g. 22]
    Version 120.0.2210.91 (Official build) (64-bit)

VSCode Version 1.85.1
Zulu JDK 17 Azul Zulu: 17.46.19 64bit for Windows.

Additional context
There is no JavaHome setting in VScode that can be "added. For some reason, the app simply wants to use Java/JDK-17 which is not installed.

"Workaround": Have you found any ways to sidestep the problem?
There is no workaround.

"Urgency": How severe is this problem? "Business stopping" vs "Not business-stopping".
Not-business stopping. Trying to use the product.

Config settings from settings.json in VSCode:
{
"terminal.integrated.allowChords": false,
"git.autofetch": true,
"redhat.telemetry.enabled": false,
"bracketPairColorizer.depreciation-notice": false,
"gitlens.advanced.messages": {
"suppressGitDisabledWarning": true
},
"salesforcedx-vscode-apex.advanced.enable-completion-statistics": true,
"salesforcedx-vscode-core.retrieve-test-code-coverage": true,
"diffEditor.codeLens": true,
"editor.largeFileOptimizations": false,
"salesforcedx-vscode-apex-debugger.connectionTimeoutMs": 40000,
"editor.accessibilitySupport": "off",
"[python]": {
"editor.formatOnType": true
},
"diffEditor.ignoreTrimWhitespace": false,
"git.openRepositoryInParentFolders": "always",
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"xml.java.home": "",
"window.zoomLevel": -1,
"javaHome": "C:\Program Files\Zulu\zulu-17"
}

@TroyCen , this isn't an issue with the extension. It's an issue with the underlying plugin.
What is the value of the javaHome property in your ~/.sfdx-scanner/Config.json file?

Repeated the Following Setup Steps.

  • In your terminal, run sfdx plugins:install @salesforce/sfdx-scanner. Make sure that you’re running Code Analyzer version 3.16.0 or later. [Confirmed 3.19]
  • Install Code Analyzer (beta).

I have spent about an hour looking for the ~/.sfdx-scanner/Config.json file. Do you have some idea where that is?

~ is your home directory. Looks like you're on Windows, so that'll be \user/[your user name]. The leading . in .sfdx-scanner denotes it as hidden, so it might not display by default in the File Explorer. I believe you can use ctrl-h to show hidden files/folders.

And to clarify, the reason that this is happening is because the config file I'm talking about has a javaHome property that determines what version of Java the scanner will attempt to use. From what you're describing, it sounds like that property references a version of Java that no longer exists on your machine.

Ahh THERE IT IS! There's a checkbox to show hidden files.
It's now working.

THANK YOU. Suggest adding to instructions for those who do not use Java, but use some OpenJDK. (We use Zulu).

Final Solution, (Windows 10/11)
In your terminal, run sfdx plugins:install @salesforce/sfdx-scanner. Make sure that you’re running Code Analyzer version 3.16.0 or later. [Confirmed 3.19]
Install Code Analyzer (beta).
Go to File Exporer, show hidden files, go to ~/.sfdx_scanner (c:\Users\YourUsername.sfdx_scanner (hidden).
Open Config (config.json) with VSCode.
Update the last line javaHome with your Java home directoy. For Zulu, it was C:\\Program Files\\Zulu\\zulu-17.

@TroyCen , Zulu shouldn't be an issue. Basically, if javaHome is absent, we set it to one of the JDKs present on the machine. Sounds like that property was initially set, and then the version the property references got removed.
Happy to help, though, and glad it's all sorted out.