JVM does not update file's Last Modified Time

Here is a sample program I used:

import java.io.*;

import java.util.*;

public class TestFile {

public static void main(String[] args) throws Exception {

FileWriter out = new FileWriter("1.txt");

out.append("Just a test");

out.close();

}

}

On first time program runs ok - it creates a file named "1.txt" and writes "Just a test" into it. Last Modified field is ok.

But when I try to run this class second and more times - Last Modified field is not changed!

I tried to install jdk14, jdk16-beta - it doesn't help.

What's wrong? This affects my work with Eclipse and SVN - when I save files in Eclipse "Last Modified" field isn't updated and Subversion doesn't see changes. It is very bad

My primary OS is WinXP SP2

java version "1.5.0_05"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)

Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)

I tried this example class on FreeBSD and it works fine!

FreeBSD java version "1.5.0"

Java(TM) 2 Runtime Environment, Standard Edition (build diablo-1.5.0-b00)

Java HotSpot(TM) Client VM (build diablo-1.5.0_06-b00, mixed mode)

FreeBSD ***.com 6.1-STABLE FreeBSD 6.1-STABLE #0: Sat May 13 18:14:51 EEST 2006root@***.com:/usr/obj/usr/src/sys/*** i386

[1369 byte] By [pudila] at [2007-10-2 20:20:22]
# 1

I'm not sure if this will help, but I use this to append information to a file and it always shows the modified date/time when I check the file properties after.

try {

BufferedWriter out = new BufferedWriter(new FileWriter("C:/...", true));

out.write("Write output");

out.close();

}

catch (IOException e) {

System.err.println("error: " + e.toString());

System.exit(1);

}

KittieMalicea at 2007-7-13 23:02:42 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
I'm having the same problem. Did you find a resolution?It appears to happen only on my laptop with an intel duo processor. Other machines seem OK.
SHeinricha at 2007-7-13 23:02:42 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
Are you by chance using ZoneAlarm 6.5?That was my problem!see http://forum.zonelabs.org/zonelabs/board/message?board.id=Antivirus&message.id=11679
kmorgan1178a at 2007-7-13 23:02:42 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4

What a great tip about ZoneAlarm 6.5.

It was causing two problems for me (that I didn't connect with ZA).

The probs were:

1) Update of date/time stamp was not occurring when I made file changes, within Homesite 5.5

2) My various 'MS Office Tool Bar' icons all disappeared, replaced by a single 'blah' icon -- making correct app-selection laborious

I thought I was having hard-disk problems!

Then I saw your tip...

And, when I uninstalled ZA 6.5 and re-installed ZA 6.1,

it fixed both problems.

Many thanks...

jimmasters

jimmastersa at 2007-7-13 23:02:42 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5

F*cking Zone Alarm. That's wasted about a week of my time.

Thanks very much for your response. That's saved me an additional week.

... and in case Zone Labs are reading, you really need to fix that bug because it effectivley prevents anyone writting java apps (since the compile uses the timestamp to work out what to re-compile) and using CVS (since that does updates and commits based on timestamps).

SHeinricha at 2007-7-13 23:02:42 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 6
I have the same problem with ZoneAlarm 6.5. Just got an update from ZA and it seems to fix the problem. - zaAvSetup_65_722_000_en.exe
nine2003a at 2007-7-13 23:02:42 > top of Java-index,Java HotSpot Virtual Machine,Specifications...