This was tested on OSX Mavericks through virtual box, and on Yosemite on a macbook.
I have a simple executable jar named "HelloWorld.jar".
I am trying to create a .app bundle for this java application. (Obviously, my actual program is more complex, but I have whittled it down to the barest problems).
CASE 1 - SIMPLE BUNDLE WITHOUT JAVA - WORKS COMPLETELY
Step 1 - Test at Console - Works
At the console I type
echo "Hello World (no java)" > /Users/josh/Desktop/test-output.txt
I view test-output.txt and see the expected output.
Step 2 - Test with Script - Works
I make a simple bash script named test
:
#!/bin/bash
echo "Hello World (no java)" > /Users/josh/Desktop/test-output.txt
I chmod +x test
and then type ./test
, I view test-output.txt and see the expected output.
Step 3 - Create Rudimentary App Bundle - Works
mkdir -p test.app/Contents/MacOS
cp test test.app/Contents/MacOS
open test.app
I view test-output.txt and see the expected output.
CASE 2 - SIMPLE BUNDLE WITH JAVA - DOES NOT WORK
Setup
File HelloWorld.java
:
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( "Hello World" );
}
}
File myManifest
Main-Class: HelloWorld
Did the following at console:
javac HelloWorld.java
jar -cfm HelloWorld.jar myManifest HelloWorld.class
Step 1 - Test at Console - Works
At the console I type:
java -jar HelloWorld.jar > /Users/josh/Desktop/java-output.txt
I get the expected output: Hello World
Step 2 - Test with Script - Works
I make a simple bash script named "helloworld"
#!/bin/bash
java -jar HelloWorld.jar > /Users/josh/Desktop/java-output.txt
I chmod +x helloworld
and then type ./helloworld
, I get the expected output: Hello World
Step 3 (With Java) - Does not Work
mkdir -p helloworld.app/Contents/MacOS
cp helloworld helloworld.app/Contents/MacOS
cp HelloWorld.jar helloworld.app/Contents/MacOS
open helloworld.app
I get the following error:
LSOpenURLsWithRole() failed with error -10810 for the file /Users/josh/Desktop/helloworld/helloworld.app
/user/Josh/desktop/java-output.txt
appears, but has no text inside.
As you can see, it appears that something is happening where running java inside an .app bundle is giving me that -10810 error.
Note: I also tried a variation of the first example, where I had the bash script launch /Applications/TextEdit.app, and that worked successfully. It makes me suspect the problem is with java specifically.
Does anyone have any idea what's causing this problem and how I can fix it?