0

i'm developing a java application using Netbeans 8.0.2 and I need to create the .app file for Mac OS X. The application needs two folder ("logs" and "res" to run correctly, the former contains txt log files, the ladder containing sqlite db and images).

Netbeans provides the functionality "package as -> Image Only" enter image description here

1) Unfortunately this doesn't work: double click on .app files open and immediately close application without any error messages. in fact, folders "logs" and "res" are missing in the .app file enter image description here

2) As expected, running the jar will raise an io exception:

DaveMac:Java Dave$ java -jar AnamnesiPazienti/dist/bundles/Anamnesi\ Pazienti.app/Contents/Java/AnamnesiPazienti.jar 
    [EL Warning]: 2015-05-13 22:17:10.086--ServerSession(1569933050)--Local Exception Stack: 
    Exception [EclipseLink-7274] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
    Exception Description: An Exception was thrown while trying to create logging file [logs/persistence.txt]:[java.io.FileNotFoundException: logs/persistence.txt (No such file or directory)].

3) Manually inserting logs and res folder makes application runnable (but only using the jar inside .app image).

4) Unfortunately, this doesn't work running application from .app file. It will have same behavior like 1): application start and close in a while without any message error.

5) Running (double click) script file Anamnesi\ Pazienti.app/Contents/MacOS/Anamnesi\ Pazienti causes same error in 2) (like logs and res are missing!!!!!).

DaveMac:Java Dave$ ./AnamnesiPazienti/dist/bundles/Anamnesi\ Pazienti.app/Contents/MacOS/Anamnesi\ Pazienti 
    [EL Warning]: 2015-05-13 22:27:40.434--ServerSession(368936209)--Local Exception Stack: 
    Exception [EclipseLink-7274] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
    Exception Description: An Exception was thrown while trying to create logging file [logs/persistence.txt]:[java.io.FileNotFoundException: logs/persistence.txt (No such file or directory)].
    Internal Exception: java.io.FileNotFoundException: logs/persistence.txt (No such file or directory)

QUESTION) How should I declare the presence of logs and res folder for .app file? I suppose there are some configuration to provide in info.plist (last image), but I'm stuck without any idea! enter image description here

insilenzio
  • 918
  • 1
  • 9
  • 23
  • It's possible that the working directory is the user's home directory, making it impossible to deduce the path location. Logs should really be in ~/Library/Application Supprt/{Your app} for easy refernce – MadProgrammer May 13 '15 at 21:29
  • Thanks for the reply! I've tried this solution, but: 1) I didn't find any folder relative to my application. So I've created ~/Library/Application Support/Anamnesi Pazienti ("Anamnesi Pazienti" is bundle name), but It doesn't work. 2) I've event tried ~/Library/Application Supprt/AnamnesiPazienti, but still doesn't work. Sorry, but I'm not sure about the paths I've tried? Any hint? – insilenzio May 14 '15 at 06:41
  • 1
    I usually use `System.getPropety("user.home")` to get the user's home directory and then append the `/Library/Application Support` to it. Know though, this is suppose to be used to place configuration and output files which your program generates, it's not a "magical" location where content from your app bundle appears – MadProgrammer May 15 '15 at 00:01
  • Thanks for your support! I'm going to make changes to moving files in Application support folder. – insilenzio May 16 '15 at 08:01

0 Answers0