0

I want to run java -jar from the JDK directory on my system:

D:\Users\djpastis\Downloads\fmw_12.2.1.4.0_wls_Disk1_1of1>C:\Program Files\Java\jdk1.8.0_162\bin\java

but I have this error, even the path is OK

'C:\Program' is not recognized as an internal or external command, operable program or batch file.
3
  • 1
    You should be using this syntax, "%ProgramFiles%\Java\jdk1.8.0_162\bin\java.exe" -jar "F:\ull\Path To\filename.jar" In your case, if filename.jar is in D:\Users\djpastis\Downloads\fmw_12.2.1.4.0_wls_Disk1_1of1 as that is clearly your current directory, you could just use "%ProgramFiles%\Java\jdk1.8.0_162\bin\java.exe" -jar "filename.jar". Commented Aug 18, 2020 at 14:39
  • 1
    @Compo, I have been multiple places wherre Microsoft apps would be installed to "%ProgramFiles%", but most third-party apps (7-Zip, Beyond Compare, git, etc.) would be installed to a `D:\Program Files" directory. How would you deal with that? Commented Aug 19, 2020 at 15:08
  • 1
    I wouldn't use the standard location variable %ProgramFiles% @lit, or I may parse the registry user shell folders to determine the default location first. In this specific case however, the OP used 'C:\Program' is not recognized as an internal or external command…, which meant that the standard default would generally be okay! I will say however, that modern Windows Operating Systems, by default install to the drive allocated to C:. Commented Aug 19, 2020 at 17:06

1 Answer 1

4

Paths containing special characters, such as a SPACE, must be quoted. Microsoft put a SPACE characters in there for you. :-) The only reliable, safe way is to always quote paths.

"%ProgramFiles%\Java\jdk1.8.0_162\bin\java.exe"
Sign up to request clarification or add additional context in comments.

1 Comment

@Compo is right, the enviromment variable should (must) be used.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.