3

My game executes and saves wonderfully on Windows 7, even if the folder I save to doesn't exist. I used the following code (roughly):

new File("Data/Saves").mkdirs();

The problem occurred when I sent it to my friend with Windows 8. He said that the Data folder was nowhere to be found, and it wasn't saving anything. Obviously a huge problem. Is there a compatibility problem or a workaround? Is it even the OS?

Monkeybro10
  • 267
  • 1
  • 4
  • 8
  • Could be a security issue with Windows 8 (Windows 7 is bad enough). What version of the JDK are you using and what is the absolute path you are trying to create?? – MadProgrammer Feb 12 '13 at 00:34
  • Have you tried using absolute path (c:/some/folder)? Is there any exception thrown? – Pshemo Feb 12 '13 at 00:36
  • I wanted to avoid absolute paths. It creates the folder in the same directory as the Jar though, if that's any help. I can't really test it on my own though as I have Windows 7. – Monkeybro10 Feb 12 '13 at 00:41
  • As for my JDK I'm not really sure. In Eclipse it says my compiler compliance level is set to 1.6. – Monkeybro10 Feb 12 '13 at 00:43
  • @Monkeybro10 Well done for wanting to avoid absolute paths. Can you tell us the path that the application is using when you run it right now? – MadProgrammer Feb 12 '13 at 00:44
  • The program works flawlessly on my computer with the Jar placed on my desktop. When I run it, it makes a "Data" folder right next to it, and a "Saves" folder inside of that, which is where my game puts all of its junk. My friend with win8 put the jar in his documents and said he couldn't find a Data folder anywhere, which would explain why he can't get past Level 1 or save anything. – Monkeybro10 Feb 12 '13 at 00:47
  • 1
    @Monkeybro10 Hmm, I would have thought "Documents" would be a save place. You could try creating a really simple program that just tries to create folders and run it in various locations (I don't have Windows 8) to evaluate where it might be possible to run. The other choice to run the program as administrator, but that would require having Java installed under the admin user in the first place – MadProgrammer Feb 12 '13 at 00:58
  • Try to use **new File("Data").canWrite()** to determine is it possible to create a folder – Alex Apr 09 '13 at 14:21

1 Answers1

0

Try preceeding your path with the String given from new File(".").getCanonicalPath(); At least, i think it worked for me, but i have currently no acces to any Win8-System…

rhavin
  • 1,512
  • 1
  • 12
  • 33