'C:\' in CMD, the filename, directory name, or volume label syntax is incorrect

46,843

Solution 1

  1. press Windows-key and Pause-key together WinPause
  2. select "Advanced system settings"
  3. in "System Properties" press the button "Environment Variables"
  4. select "Path" in the upper part and press "Edit...":

    enter image description here

  5. append ;%ProgramFiles(x86)%\Java\jdk1.7.0_40\bin to the path:

    enter image description here

  6. OK

Solution 2

Instead of

C:\program files\

put

C:\progra~1\

Solution 3

It is not very clear what the problem is. It looks like you installed java to C:\Program Files(x86)\Java\jdk1.7.0_40 and wants to use javac to compile a program.

  • Start cmd
  • set path=C:\Program Files(x86)\Java\jdk1.7.0_40\bin;%path%

  • Create a Java class (HellowWorld.java)

  • Compile using javac HelloWorld.java
  • Run it using java HelloWorld
Share:
46,843
Collin Tinen
Author by

Collin Tinen

Software Engineer @ IBM

Updated on November 25, 2020

Comments

  • Collin Tinen
    Collin Tinen over 3 years

    Recently started trying to learn java and the first thing I needed to do was to make a PATH variable. My path variable looks like this.

    C:\Users\Collin>echo %path%
    'C:\Program Files(x86)\Java\jdk1.7.0_40\bin';C:\Windows;C:\Windows\system32;
    'C:\Program Files(x86)\Java\jdk1.7.0_40\bin';C:\Windows;C:\Windows\system32;
    

    So, I attempt to use javac to see if path did work. Javac did not work, showing the error of not recognized as an internal or external command, operable program, or batch file. I then tried just using path and I got this:

    C:\Users\Collin>%path%
    The filename, directory name, or volume label syntax is incorrect.
    

    I then tried to just use basic explorer paths such as 'C:\' and tried another drive as 'G:\'. I've tried almost every variation of quotations and formatting but nothing seems to work.

    C:\Users\Collin>C:\
    'C:\' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\Collin>'C:\'
    The filename, directory name, or volume label syntax is incorrect.
    
    C:\Users\Collin>"C:\"
    '"C:\"' is not recognized as an internal or external command,
    operable program or batch file.
    
    C:\Users\Collin>'G:\'
    The filename, directory name, or volume label syntax is incorrect.
    

    I'm running Windows 7 Ultimate 64-bit as my OS. Will I have to just format my HDD? This seems to be a problem with the registry, and as such I'm thinking that I will have to format and reinstall. But, maybe there is something I didn't catch that you guys can? Any help would be greatly appreciated, even if you tell me I have to format. Thanks in advance.