'java command works in command prompt but not in powershell
I have following problem. I installed new OpenJDK 17:
c:\java\jdk-17.0.2
I've set up JAVA_HOME to it and added to path:
JAVA_HOME\bin
in cmd when I type java -version it works. But when I run it from VS code or powershell it says following:
Error: could not open C:\java\jdk-17.0.2\lib\jvm.cfg'
Has anybody faced similar issue?
Thanks, M.
UPDATE #1:
here are my env variable settings:

path:
Solution 1:[1]
Here are 5 steps you can follow to fix the issue:
- In the run dialog box, enter
sysdm.cpl - In the window that came up, navigate to Advanced tab.
- Click on the Environment Variables button.
- Add the location of your java installation (the bin directory) to the PATH variable.
;%ProgramFiles%/Java/jre%version%/bin
followed by a semi-colon ;
Do the following and check again with a new PowerShell prompt
5.1. Add a
JAVA_HOMEvariable equal to something like:C:\Java\JDK-17.0.25.2. Add
%JAVA_HOME%\binto the beginning of your PATH variable.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |


