ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <>
Subject Re: Possible Bug? Ant task <jar> does not handle files with over 255 chars in the path name
Date Mon, 26 May 2008 14:59:59 GMT
This is really a limit on the Windows system itself and not Java or
Ant. Although in theory it is possible to have longer file names in
Windows, the cutoff in real life is about 255 characters. This
includes the directories, the directory separators, and the drive
letter and colon.

This has to do with the older Windows library function in order to
open a file. There is a newer call in order to do this, and that could
allow you to use a file name up to 25K. However, Windows itself uses
the older style function.

Try an experiment:

* Open Windows Explorer, and create a directory called
That's a path of 152 characters in its name.

* Open a DOS command and execute the following command:

subst Q: C:\abcdefghijklmnopqrstuvwx\abcdefghijklmnopqrstuvwx\abcdefghijklmnopqrstuvwx\abcdefghijklmnopqrstuvwx\abcdefghijklmnopqrstuvwx\abcdefghijklmnopqrstuvwx

This will create a drive called "Q:" that has as its root the
directory you just created.

* Now create a directory called
in Windows Explorer. Again, that has 152 characters in its directory name.

* Create a text file called "FOO.txt" in that directory on drive Q:

* From your C:\ drive, try to access that file FOO.txt using Windows
Explorer. You will get an error   that the directory name is illegal.
Windows is unable to access the file because the name from the root of
the drive is longer than 255 characters.

* To get rid of the file. Delete it from the Q: drive and then delete
the directory from the Q: drive. Then run "subst q: /d" to remove the
Q: drive. After that, you can remove the rest of the directory via the
C: drive.

On Fri, May 23, 2008 at 9:08 AM, Adrian Muscalu <> wrote:
> Hello,
> I am running an ANT script on my Win XP machine; one of the tasks attempts to create
a jar file where the class files are in a directory with a long name. The combined path, package
name and file name exceedes 255 characters.
> Expected result:
> The script should fail as the files exceed the Windows XP file system limitation.
> Actual result:
> The build finishes with a successfull state although the files that have the long name
in the soturce directory have not been included into the jar.
> I was hoping for ANT to report on the problem and stop the build; Ant managed to create
the long named files just fine, but any subsequent operation on them (copy, jar) fails without
notification. Any attempt to work with the files on the Windows DOS prompt (copy command)
ends with a pertinent message saying that the file name is too long and the operation fails.
> Is this a bug? I don't expect ANT to fix the XP limitation, just to report on it somehow.
> Thank you,
> Adrian
> _________________________________________________________________
> News, entertainment and everything you care about at Get it now!

David Weintraub

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message