0

I'm developing a javafx application that uses logging to a file, and does some processing to a file that is backuped in a folder in the project structure. The problem is that neither the file of the log (nor the logging.properties file), and the temp folder to save the files are copied into the deployed package. The project structure is as this:

-src
-test
-resources
    -config
        *logging.properties
    -css
    -view
    -images
    *file1.json
    *file2.json
-temp
    *temp_file1
    *temp_fileN
*log.txt

The resources folder is copied fine with all the css, fxml and images, and also the two json files that are used to store data. But the log.txt in the root of the project is not there when the application is used, nor the config and temp folders. I have the build.xmlfile fixed with the following lines, that I know works for the resources stuff, but doesn't solve my problem:

<filelist>
    <file name="${java.home}\..\lib\ant-javafx.jar"/>
    <file name="${java.home}\lib\jfxrt.jar"/>
    <file name="${basedir}"/>
</filelist>

...

<fx:resources id="appRes">
    <fx:fileset dir="dist" includes="MyApp.jar"/>
    <fx:fileset dir="dist" includes="libs/*"/>
    <fx:fileset dir="dist" includes="resources/**"/>
</fx:resources>
ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
transgressoft
  • 155
  • 2
  • 13
  • May be I am missing something but where are you copying the `temp` and `log.txt` ? – ItachiUchiha Nov 10 '15 at 04:26
  • I don't copy `temp` and `log.txt`. There are in my project and when i run it, it's all fine. But when I deploy it for example in a dmg and I run the .app, the log file isn't in the contents and the functionality that make that process on a file and makes a mackup in temp cannot be done, and I think is because it throws an IOException cause the temp folder isnt there. – transgressoft Nov 10 '15 at 10:22
  • I think that is correct, you should not be keeping logs inside a file. For example, an `.app` file is no different than a `.jar` file, which is nothing but a bundle of may other files. You cannot into the files inside a jar. Therefore. it is always advised to keep files, which are not read-only, outside the jar files. – ItachiUchiha Nov 10 '15 at 10:47
  • I don't follow you. As I wrote in the question, I have also 2 .json files that I use to store/read data while the application is running. It's ok if I can't have the log file, but I need a temp folder. And it has to be inside the application bundle. – transgressoft Nov 10 '15 at 11:12
  • Take some time and go through [this answer](http://stackoverflow.com/a/10161092/1759128). – ItachiUchiha Nov 10 '15 at 13:27
  • I see it now, thank you. I will ask the user in the first application use where to store the files, and I'm going to use the system specific temp folder. Thanks again! – transgressoft Nov 10 '15 at 14:37
  • @ItachiUchiha now I have a similar problem reading (not writing as in this previous question) a config.properties that must be included in the deploy. The file is at `/resources/config/` and must be included since the application needs an API key & secret stored there, (it cant be in the source code because is in a public repository and I should keep the API key). Do you know how I can fix this? I didn't want to open a new SO question just for a very similar one made by me. Thanks in advance. – transgressoft Jan 25 '16 at 15:56

0 Answers0