Thank you very much for your insights.
I have restructured my resources and now have two things in my resources folder:
A folder named jre, containing the jre.
A folder named desktop-1.0 containing the contents of the prior jar file.
To start the java process I am using this code in a binary located in the MacOS Folder. It is the first thing that gets executed
NSBundle* myBundle = [NSBundle mainBundle];
NSString* absPath = [myBundle resourcePath];
NSTask *task = [[NSTask alloc] init];
task.launchPath = [NSString stringWithFormat:@"%@%s", absPath, "/jre/bin/java"];
task.arguments = @[@"-XstartOnFirstThread", @"-cp", [NSString stringWithFormat:@"%@%s", absPath, "/desktop-1.0"], @"software.mayr.rougelike.desktop.DesktopLauncher"];
[task launch];
Now the app can start, but it instantly crashes with this in the error report:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn't posix_spawn: error 1'
terminating with uncaught exception of type NSException
abort() called
I suppose that it is either not allowed to start tasks from a sanboxed App or that the java executable is not correctly signed.
I have signed it once with just the
<key>com.apple.security.app-sandbox</key>
<true/>
value, and once with these two:
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.inherit</key>
<true/>
I tried both, because I was not sure if this process needs to keep the same sandbox as the main process, or if it should use a separate one.