Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

strange phenomenon that %JAVA_HOME% is not dir-able

I have set %JAVA_HOME% as "C:\Program Files\Java\jdk-23".

When I echo %JAVA_HOME%, it will return "C:\Program Files\Java\jdk-23:. When I cd %JAVA_HOME%, it will take me to "C:\Program Files\Java\jdk-23".

but when I "dir %JAVA_HOME%, it will complain that

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The system cannot find the path specified.

This is so strange. what’s wrong?
enter image description here

Incidentally, I have set my JAVA_HOME to "C:\Program Files\Java\jdk-23". But where java returns "C:\Program Files\Common Files\Oracle\Java\javapath\java.exe". Does it matter?

>Solution :

The issue is that the %JAVA_HOME% path contains spaces, which are delimiters, so it won’t find the correct file
The solution is to change your command to:

dir "%JAVA_HOME%"

cdworks because, as per the documentation,

Spaces aren’t treated as delimiters, so can contain spaces without enclosing quotation marks. For example:
cd username\programs\start menu

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading