Telling .jar file to make a file on the Desktop instead of within itself (java) mac
<p>I have a program which includes the following line of code:</p>

<pre><code>//String s = fileName;
File location = new File(s);
</code></pre>

<p>and then I have </p>

<pre><code>//String contents = whatIWantToPrint;
OutputStream print = new FileOutputStream(location);
    print.write(contents.getBytes());
    print.close();
</code></pre>

<p>telling the program to print the string contents to the file s. However the file appears within the folder that the program is in rather than the directory in which the program is in. For example if the program is on the persons desktop I want it to make the file on their desktop. </p>

<p>I used the following line in terminal to make the program a jar file (mac):</p>

<pre><code>jar -cvmf manifest.txt Generate.jar *.class
</code></pre>

<p>Someone told me to do this:</p>

<pre><code>String dir = System.getProperty("home.dir"+"/Desktop");
    String filePath = dir + File.separator + ss + ".txt";
    File location = new File(filePath);
</code></pre>

<p>But I'm not sure if that's what will make the program make the file in the desktop and it also throws a security exception so it doesn't work anyways</p>