File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Java deletion sometimes fails on Windows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java deletion sometimes fails on Windows" Watch "Java deletion sometimes fails on Windows" New topic

Java deletion sometimes fails on Windows

Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 196
Hi all,
I have the following code which simply deletes a file. When I run this code in my local machine it works fine but when I run it on a batch server (a server for running standalone Java apps as batch jobs), it fails...

What could be the reason? It looks like I have write permissions, but still the file is not deleted.

Thanks for any help.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

On Windows you can't delete a file that is open for reading or writing. Probably on the server some other process or thread hasn't closed the file yet.

On UNIX you can do this, by the way; current clients of the file don't see any change, but otherwise the file disappears.

[Jess in Action][AskingGoodQuestions]
Rob Spoor

Joined: Oct 27, 2005
Posts: 20271

If the file is not still open, does the file or parent folder have any rights on it that prevent you from removing it?

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Java deletion sometimes fails on Windows
It's not a secret anymore!