Skip to content

Java And Windows

I can’t believe that Java is now 19 years old and people are still asking about how to deal with path-like structures and spaces in Java.

It is really very simple: avoid using spaces :-)

You can do “dir /x” in a command prompt window, find out what the short pathname for a directory is and just use that version wherever needed. Viz.:

You will usually (UNLESS you have been tweaking one of NTFS’s more esoteric parameters, in which case…stop tweaking) find that “Program Files” is ‘PROGRA~1′. This form can be used anywhere with no problems.

For example:

set JAVA_HOME=R:\PROGRA~1\Java\jdk1.7.0_25
PATH %JAVA_HOME%\BIN;%PATH%

Etc.

Simple. There’s no need to avoid the nice human-readable paths usually used in Windows.

Seriously, it isn’t a problem, guys!

It hasn’t been a problem since at least NT4.0 (which is as far back as I go, anyway).

For reference: DIR.

BOB
Update: This of course applies to any JVM-based language/system, including Groovy.

Tags: , ,

C, Java Enterprise Edition, JEE, J2EE, JBoss, Application Server, Glassfish, JavaServer Pages, JSP, Tag Libraries, Servlets, Enterprise Java Beans, EJB, Java Messaging Service JMS, BEA Weblogic, JBoss, Application Servers, Spring Framework, Groovy, Grails, Griffon, GPars, GAnt, Spock, Gradle, Seam, Open Source, Service Oriented Architectures, SOA, Java 2 Standard Edition, J2SE, Eclipse, Intellij, Oracle Service Bus, OSB