Sunday, December 18, 2016

Avoiding spaces using alternate 8.3 names

Sometimes you get a silly and annoying error like:

> Files\Java\jdk1.8.0_111"" was unexpected at this time.

This is a clue that the space in "Program Files" has thrown something off.

If you have set JAVA_HOME, for example, as

 JAVA_HOME=c:\Program Files\Java\jdk1.8.0_111

then elsewhere we use it as %JAVA_HOME%, other programs will fail because they will see that space and think that

 JAVA_HOME=c:\Program
which is of course wrong, and they will also be completely baffled about what to do with
 Files\Java\jdk1.8.0_111
The extra double quote(s) in the message indicate that one piece of software (or perhaps you yourself) attempted to camouflage that space by doing something like:
 JAVA_HOME="C:\Program Files\Java\jdk1.8.0_111"
which works for *some* programs, but not all.

A better and more reliable way to avoid that space is to use the alternate 8.3 name for C:\Program Files, often called the "tilde name" because it usually contains the "~" name in it.

To find the alternate 8.3 name for C:\Program Files, open up CMD.EXE and do:

 cd \
 dir /x pro*
You should see something like:
  Directory of C:\

 10/23/2016  10:07 AM    <DIR>          PROGRA~1     Program Files
 12/16/2016  05:47 PM    <DIR>          PROGRA~2     Program Files (x86)
PROGRA~1 is the alternate 8.3 name for Program Files, and PROGRA~2 is the alternate 8.3 name for Program Files (x86). Now go find the place where you did:
 JAVA_HOME=c:\Program Files\Java\jdk1.8.0_111
or
 JAVA_HOME="C:\Program Files\Java\jdk1.8.0_111"
and change it to
 JAVA_HOME=C:\PROGRA~1
You no longer need the quotes because there is no space in the alternate name.

After making a bunch of environment variable changes like this, it's usually a good time to re-start the computer, pour a new cup of coffee, and move on to see what the next problem might be.

Good luck!

No comments:

Post a Comment