0

Possible Duplicate:
Storing a file in the user’s directory in cross-platform Java

I am working on a java project and the java application ends up making some .class files. Currently, these files are stored inside a projects directory inside the main application directory. Some people who run the application on a network with a certain version of Novel security software experience issues sometimes when these .class files are created or modified. I would like to instead always store these files locally but I am unsure of where to store them on the PC version. On the Mac I think I will store them in application support but I do not know of a similar place on the PC. Also, it would be best if there was a location that would be good for XP Vista and 7 but if I had to have specific locations for each OS that would be sufficient as well.

Community
  • 1
  • 1
Mike2012
  • 7,629
  • 15
  • 84
  • 135
  • See also http://stackoverflow.com/questions/1570757/storing-a-file-in-the-users-directory-in-cross-platform-java – trashgod Jan 07 '10 at 20:27

3 Answers3

4

Use the %AppData% environment variable? I suppose you'd just need to add it to CLASSPATH...

codekaizen
  • 26,990
  • 7
  • 84
  • 140
2

If the app is generating these at runtime, and you don't need them permanently you could also store them in the temp directory. You can access the temp directory in a platform independent way in Java via the system property: System.getProperty("java.io.tmpdir").

Jeremy Raymond
  • 5,817
  • 3
  • 31
  • 33
0

You could look for the "user" directory. In that directory, there's an "appData" directory.

On Vista, it's "C:\Users\Username\AppData".

On XP, i don't quite remember the name. But These are special folders for Windows so I'm sure you can specify one name and go to it directly.

Danielle Paquette-Harvey
  • 1,691
  • 1
  • 16
  • 31
  • Note that it's not always there, due to machine policy. The best way is to use the %APPDATA% variable. This also insulates you from needing to differentiate between Windows versions. – codekaizen Jan 07 '10 at 20:31
  • Yeah you're right. I don't usually store files on computers, we use the registry to store info that we need. – Danielle Paquette-Harvey Jan 08 '10 at 13:07