Java is not a “Program Files”
I don’t know how many times I’ve been through the scenario. Key “java.sun.com” into the address bar. Click around a few times, getting side tracked by JavaFX or the new WTK or whatever. “Where’s that JDK link again?” Finally find the link to the JDK. Check the box next to the link. “Wait a sec! I can just click the link.” Begin the lengthy download. Begin the install process. Hi, I’m Cliff. You’re here because you put your JDK under “C:\Program Files”. No matter how many times I go through the process, I always make the same mistakes. I always get distracted by some non-jdk link that spins me off on a tangent. I always get confused which link is the JDK, which is the JRE, which one is yucky EJB. I always check the box next to the download link but never use Sun’s download manager. (Who needs to install yet another piece of software to download one file?) And I always, ALWAYS get tempted to install the JDK under “C:\Program Files”.
If you’re new to this site, relax. There’s a strong point buried somewhere in the text. If you’re new to java don’t install to “C:\Program Files”. It’s tempting but dangerous. Here’s what’ll happen. You complete your install. Everything is cool and you’re now a Java programmer. The birds will sing at 7am and the espresso will smell just splendid. Then one day it will happen. You’re running a piece of software, written in Java. You’re getting some crazy error, yet you’ve followed the instructions to the letter. You’re frustrated beyond belief. You write to all the user forums with no definitive answer. Eventually one day (several months later), a piece of the error message becomes clear. The program is complaining about invalid argument, “Files”. If you know like I know, you’ll realize the problem is rooted in the way some apps (Laszlo, Maven plugins, etc.) attempt to track down your local Java installation, then reuse the path as a command line string without quoting or escaping for potential white-space. In other words, somewhere the app is saying, “set JDKHOME = where your jDKHOME is installed. Ok, now run JDKHOME/bin/javac somefiles”. When JDKHOME expands, the whitespace is interpreted as the end of the comand and the beginning of your arguments. You end up running a command named “C:\Program” and giving it an initial argument “Files/bin/javac”. The command interpreter does not recognize C:\Program as a command or an executable file so it coughs.
- Posted in: Programming