title: Needing to type full path to save file?
body: <p>Okay, this is my first post here, sorry if i did something wrong. (please let me know if i did aswell)</p>
  
  <p>So i've been trying to make a "data" folder with a audio(.wav) file in it when the runnable jar file is run but for some reason it doesn't work, i've tried to get this working for the last week but i finally kinda gave up on trying to get it working without help(other than searching around the internet) and therefore ask here.</p>
  
  <p>So i have this code:</p>
  
  <pre><code>public static void loop(String path, int volume) {
      try {
          if (volume &gt; 6) throw new IllegalArgumentException("Requested volume ("+volume+") is higher than allowed. (maximum 6)");
          else if (volume &lt; -80) throw new IllegalArgumentException("Requested volume ("+volume+") is lower than allowed. (minimum -80)");
          else {
              Clip clip = AudioSystem.getClip();
              clip.open(AudioSystem.getAudioInputStream(new File(path)));
              clip.loop(Clip.LOOP_CONTINUOUSLY);
              FloatControl gain = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
              gain.setValue(volume);
              clip.start();
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>for looping a .wav file continuously and it works, then i try to save the file with this code:</p>
  
  <pre><code>public void save(String music, String output) {
      try {
          File sound = new File(music);
          AudioInputStream ais = AudioSystem.getAudioInputStream(sound);
          AudioSystem.write(ais, AudioFileFormat.Type.WAVE, new File(output));
      } catch (IOException | UnsupportedAudioFileException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>And that seems to work aswell when i do something like this:</p>
  
  <pre><code>save("D:\\Eclipse\\eclipse\\workspace\\Test\\data\\music.wav", "C:\\Users\\Karim\\Desktop\\data\\test.wav");
  loop("C:\\Users\\Karim\\Desktop\\data\\test.wav", -30);
  </code></pre>
  
  <p>But if i try to do this instead:</p>
  
  <pre><code>private File jar() {
      try {
          File jar = new File(Game.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
          return jar;
      } catch (URISyntaxException e) {
          e.printStackTrace();
      }
      return null;
  }
  private File data = new File(jar().getParentFile().getPath()+File.separator+"\\data");
  private File music = new File(data.getPath()+"\\music.wav");
  save(music.getPath(), "C:\\Users\\Karim\\Desktop\\data\\test.wav");
  loop("C:\\Users\\Karim\\Desktop\\data\\test.wav", -30);
  </code></pre>
  
  <p>it won't save the file, why is that and what can i do to make it save?</p>
  
  <p>Final Notes:</p>
  
  <ol>
  <li>I'm pretty new to java.</li>
  <li>I'm pretty new to programming in itself.</li>
  <li>I don't want to use a library, i wanna try to make it work without and i'm so close.</li>
  <li>If i forgot to say anything please let me know and i'll edit this post or make a comment.</li>
  </ol>
  
  <p>EDIT: Just wanted to make it clear that this works in the IDE but not when i export it. Also i have the data folder both IN the 'src' folder and beside the 'src' folder, just for testing.</p>