title: My executable .jar file won't write a save file
body: <p>I'm making a game for a school assignment, one of the features is that the game can be saved and loaded. While in eclipse everything worked but after making it an executable jar it won't create the file at the specified location.</p>
  
  <p>I am using this code to get it to save in the folder I want:</p>
  
  <pre><code>see below for full code
  </code></pre>
  
  <p>Note that the folders, quarto &amp; savefiles, are created but the save file itself isn't.</p>
  
  <p>I'm writing object to a .sav file using this code:</p>
  
  <pre><code>see below for full code
  </code></pre>
  
  <p>Does this have to do with permissions?</p>
  
  <hr>
  
  <p>Edit: Ran it in cmd, no exceptions when i tried to save. Added a java.policy file to the folder the jar was in, no difference. I got a previously saved file and put it in the quarto/savefiles map because I wanted to see if it did load correctly (this also uses the user.home to get to the right folder). It loaded correctly. I also searched for the savename.sav to see if it saved it somewhere else, didn't find anything.</p>
  
  <p>Full class:</p>
  
  <pre><code>package quarto;
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.ObjectOutputStream;
  
  public class TaskSpelOpslaan extends SpelGegevens{
  
  
  public static void runSpelOpslaan() {
  
      String savename = SpelOpslaanScherm.getSaveName();
      String userHome = System.getProperty("user.home") + File.separator + "quarto" + File.separator + "savefiles";
      String locatie = userHome;
      File folder = new File(locatie);
      if (!folder.exists()) {
         folder.mkdirs();
      }
  
      try{ 
          if(!savename.contains(".sav"))
          {
              savename = (savename+".sav");
          }
          else
          {
              return; 
          }
          FileOutputStream saveFile=new FileOutputStream(folder+File.separator + savename);
  
          ObjectOutputStream save = new ObjectOutputStream(saveFile);
  
          save.writeObject(bordInfo);
          save.writeObject(stukGeplaatst);
          save.writeObject(stukGeselecteerd);
          save.writeObject(spelerBeurt);
          save.writeObject(gekozenStuk);
          save.writeObject(bordImage);
          save.writeObject(stukImage);
          save.writeObject(naamSpeler1);
          save.writeObject(naamSpeler2);
  
          save.close(); 
  
      }
      catch(Exception exc){
          exc.printStackTrace(); 
      }
  }   
  }
  </code></pre>
  
  <p>EDIT2: I'm thankful for all your help, but I just realized a really stupid mistake i made... else{return;} didn't do what I taught it did and could be removed altogether.
  Sorry for the trouble!</p>
  
  <p>Is there anyway to mark this question closed or should i just let it sit?</p>