You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 4, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+24-23Lines changed: 24 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,38 +9,39 @@ A BASH based *JavaApplicationStub* for Java Apps on Mac OS X that works with bot
9
9
Why
10
10
---
11
11
12
-
Whilst developing some Java apps for Mac OS X I was facing the problem of supporting two different Java versions – the "older" Apple versions and the "newer" Oracle versions.
12
+
Whilst developing some Java Apps for Mac OS X I was facing the problem of supporting two different kinds of Java versions – the old Apple versions and the new Oracle versions.
13
13
14
14
**Is there some difference, you might ask?** Yes, there is!
15
15
16
16
1. The installation directory differs:
17
-
* Apple Java 1.5/1.6: `/System/Library/Java/JavaVirtualMachines/`
17
+
* Apple Java 1.5/1.6: `/System/Library/Java/JavaVirtualMachines/` or `/Library/Java/Home/bin/java`
2. Mac Apps built with tools designed for Apple's Java (like Apple's *JarBundler* or the OpenSource [ANT task "Jarbundler"](https://github.com/UltraMixer/JarBundler)) won't work on Macs with Oracle Java 7 and no Apple Java installed.
22
-
* This is because Apple's `JavaApplicationStub` only works for Apple's Java and their style to store Java properties in the `Info.plist` file.
23
-
* To support Oracle Java 7 you would need to built a separate App package with [Oracles ANT task "Appbundler"](https://java.net/projects/appbundler).
24
-
* Thus you would need the user to know which Java distribution he has installed on his Mac. Not very user friendly...
22
+
* This is because Apple's `JavaApplicationStub` only works for Apple's Java and their *style* to store Java properties in the `Info.plist` file.
23
+
* To support Oracle Java 7 you would need to built a separate App package with [Oracle's ANT task "Appbundler"](https://java.net/projects/appbundler).
24
+
* Thus you would need the user to know which Java distribution he has installed on their Mac. Not very user friendly...
25
25
26
-
3. Oracle uses a different syntax to store Java properties in the applications `Info.plist` file. A Java app packaged as a Mac app with Oracles Appbundler also needs a different `JavaApplicationStub` and therefore won't work on systems with Apple's Java...
26
+
3. Oracle uses a different syntax to store Java properties in the applications `Info.plist` file. A Java Application packaged as a Mac App with Oracle's Appbundler also needs a different `JavaApplicationStub` and therefore won't work on systems with Apple's old Java...
27
27
28
28
4. Starting with Mac OS X 10.10 *(Yosemite)*, Java Apps won't open anymore if they contain the *deprecated* Plist dictionary `Java`. This isn't confirmed by Apple, but [issue #9](https://github.com/tofi86/universalJavaApplicationStub/issues/9) leads to this assumption:
29
-
* Apple seems to declare the `Java` dictionary as *deprecated* and ties it to the old Apple Java 6. If you have a newer version installed the app won't open.
29
+
* Apple seems to declare the `Java` dictionary as *deprecated* and ties it to their old Apple Java 6. If you have a newer Oracle Java version installed the app won't open.
30
30
* If Java 7/8 is installed, Apple doesn't accept those java versions as suitable
31
31
* Apple prompts for JRE 6 download even before the `JavaApplicationStub` is executed. This is why we can't intercept at this level and need to replace the `Java` dictionary by a `JavaX` dictionary key.
32
32
* This requires to use the latest [JarBundler](https://github.com/UltraMixer/JarBundler/) version (see below for more details)
33
33
34
-
*So why, oh why, couldn't Oracle just use the old style of storing Java properties in `Info.plist` and offer a universal JavaApplicationStub?!*:rage:
34
+
TL;DR: Since there is no universally working JavaApplicationStub for Java 6, 7 and above, and because Apple and Oracle really screwed things up during their Java transition phase, I was in need of a new Stub file.
35
+
And well, since I can't write such a script in C, C# or whatever fancy language, I wrote it as a Bash script. And it works!
36
+
The original script was inspired by [Ian Roberts stackoverflow answer](http://stackoverflow.com/a/17546508/1128689). Thanks, Ian!
35
37
36
-
Well, since I can't write such a script in C, C# or whatever fancy language, I wrote it as a Shell script. And it works!
37
38
38
39
How the script works
39
40
--------------------
40
41
41
-
You don't need a native `JavaApplicationStub` file anymore. The Shell script needs to be executable – that's all.
42
+
You don't need a native `JavaApplicationStub` file anymore. The Bash script needs to be executable – that's all.
42
43
43
-
The script reads JVM properties from `Info.plist` regardless of whether it's Apple or Oracle style and feeds them to a commandline `java` call like the following:
44
+
The script reads JVM properties from `Info.plist` regardless of whether it's Apple or Oracle syntax and feeds them to a commandline `java` call like the following:
44
45
45
46
```Bash
46
47
# execute Java and set
@@ -65,9 +66,9 @@ exec "${JAVACMD}" \
65
66
${ArgsPassthru:+ $ArgsPassthru}
66
67
```
67
68
68
-
It sets the classpath, the dock icon, the *AboutMenuName* (in Xdock style) and then every *JVMOptions*, *JVMDefaultOptions* or *JVMArguments* found in the `Info.plist` file.
69
+
It sets the classpath, the dock icon, the *AboutMenuName* (as Xdock parameter) and then every *JVMOptions*, *JVMDefaultOptions* or *JVMArguments* found in the `Info.plist` file. See the table below for more supported Plist keys.
69
70
70
-
The WorkingDirectory is either retrieved from Apple's Plist key `Java/WorkingDirectory` or set to the JavaRoot directory within the app bundle.
71
+
The *WorkingDirectory* is either retrieved from Apple's Plist key `Java/WorkingDirectory` or set to the JavaRoot directory within the app bundle.
71
72
72
73
The name of the *main class* is also retrieved from `Info.plist`. If no *main class* is found, an AppleScript error dialog is shown and the script exits with *exit code 1*.
73
74
@@ -80,14 +81,16 @@ There is some *foo* happening to determine which Java versions are installed –
* Symlink for old Apple Java: `/Library/Java/Home/bin/java`
83
-
3. If you require a specific Java version with the Plist key `JVMVersion` the script will try to find a matching JDK or JRE in all of the above locations
84
+
3. If you require a specific to-the-point Java version or a **minimum requirement** with the Plist key `JVMVersion` the script will try to find a matching JDK or JRE in all of the above locations
84
85
* if multiple matching JVM's are found, the script will pick the latest (highest version number)
86
+
* starting from version 3.0 of this script you can use a special syntax in Plist key `JVMVersion` to specify a **max requirement**. See [issue #51](https://github.com/tofi86/universalJavaApplicationStub/issues/51) for examples.
85
87
86
-
If none of these could be found or executed the script shows an AppleScript error dialog saying that Java needs to be installed:
88
+
If none of these can be found or executed the script shows an AppleScript error dialog saying that Java needs to be installed:
87
89
88
90

89
91
90
-
Messages are localized and displayed either in English (Default), French or German. Language contributions are very welcome!
92
+
Messages are **localized** and displayed either in English (Default), French, German or Chinese. Language contributions are very welcome! Thank you!
93
+
91
94
92
95
What you need to do
93
96
-------------------
@@ -119,7 +122,7 @@ Then place the `universalJavaApplicationStub` from this repo in your build resou
119
122
</jarbundler>
120
123
```
121
124
122
-
The ANT task will care about the rest...
125
+
The ANT task will take care of all the rest... But of course you can specify more options. Please check the JarBundler docs.
123
126
124
127
You should get a fully functional Mac Application Bundle working with both Java distributions from Apple and Oracle and all Mac OS X versions.
125
128
@@ -136,21 +139,19 @@ Just place the `universalJavaApplicationStub` from this repo in your build resou
136
139
</appbundler>
137
140
```
138
141
139
-
140
-
The ANT task will care about the rest...
142
+
The ANT task will take care of all the rest... But of course you can specify more options. Please check the Appbundler docs.
141
143
142
144
You should get a fully functional Mac Application Bundle working with both Java distributions from Apple and Oracle and all Mac OS X versions.
|**Java Main Class**|`:Java(X):MainClass`|`:JVMMainClassName`|
@@ -161,14 +162,14 @@ Supported PList keys
161
162
|**Main Class Arguments**|`:Java(X):Arguments`|`:JVMArguments`|
162
163
163
164
164
-
165
165
Logging
166
166
-------
167
167
168
-
Starting with version 2.2.0 `universalJavaApplicationStub` logs data to the `syslog` which can be easily accessed with the `Console.app` utility by searching for *syslog*:
168
+
Starting with version 3.0 `universalJavaApplicationStub` logs data to the `syslog` facility which can be easily accessed with the `Console.app` utility by searching for *syslog*:
169
169
170
170

171
171
172
+
Log data includes debug information of the JVM search strategy, App name, language, selected JVM, WorkingDirectory and exec call.
0 commit comments