File Creating Problem. [need help]

Hey Everyone,

Ok, so i have windows 8 and i have a mac also. When i play my game on the mac and windows 8 it creates the files perfectly without fail. But for some reason my friend who has windows vista home premium seems to be having a problem when he plays it. It’s not creating the saves folder with a save.txt file it. Like it said it works on all my computers. Is this a problem with him using windows vista? his java is up to date and everything.

Here is the code i’m using to create the files. Maybe someone could help me fix the problem if it can be fixed

	public static void saveGame(String path){
		try{
			File theDir = new File("saves");
			  if (!theDir.exists()) {
			    boolean result = theDir.mkdir();  
			     if(result) {    
			       System.out.println("DIR created");  
			     }
			  }
			
			File file = new File(path);
			FileOutputStream fo = new FileOutputStream(file);
			ObjectOutputStream os = new ObjectOutputStream(fo);
			
			os.writeBoolean(lvl1Complete);
			os.writeBoolean(lvl2Complete);
			os.writeBoolean(lvl3Complete);
			
			System.out.println("Game Saved.");
			os.close();
		}catch(Exception e){
			System.out.println("Could Not Save Game!");
			throw new RuntimeException(e);
		}
	}

Thanks

  • GlennBrann

What is the output it gave to the console?

It gives no errors in the console for me in eclipse. but when my friend runs it on his computer it doesn’t create the folder with the save.txt in it. But when i run it on my mac and my windows 8 it works perfectly. He is using windows vista. does that effect it from creating the files ?

If it doesn’t create the files it throws an exception at your friends computer. We are asking for that exception.

I didn’t realise that i could find out what exception he is getting. how do i do this with out using eclipse or does he have to have eclipse ?

Run the JAR from the Command Prompt.


pushd <Drag the Directory of the game>
java -jar <Drag the JAR file of the game>

ok thanks. let me get him to do that and ill get back to you guys. Thanks for the help

Ok so it seems i have fixed the problem. When he ran it using the CMD prompt it actually created the files. so now i have a .BAT file for windows users. Thanks a lot for your help everyone :slight_smile:

The culprit may be permissions given to java. If ran through CMD, it get’s some extra privileges. Did you run the CMD as administrator?

No he didn’t use the Admin CMD.