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
+67-32Lines changed: 67 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -1,73 +1,78 @@
1
1
universalJavaApplicationStub
2
-
=====================
2
+
============================
3
3
4
4
[](https://github.com/tofi86/universalJavaApplicationStub/releases)[](https://gitter.im/tofi86/universalJavaApplicationStub?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
5
6
-
A BASH based *JavaApplicationStub* for Java Apps on Mac OS X that works with both Apple's and Oracle's plist format. It is released under the MIT License.
6
+
A BASH based *JavaApplicationStub* for Java Apps on Mac OS X that works with both Apple's and Oracle's plist format. It is released under the [MIT License](https://github.com/tofi86/universalJavaApplicationStub/blob/master/LICENSE).
7
+
8
+
See the [CHANGELOG](https://github.com/tofi86/universalJavaApplicationStub/blob/master/CHANGELOG.md) for a Release History and feature details.
7
9
8
10
9
11
Why
10
12
---
11
13
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.
14
+
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
15
14
16
**Is there some difference, you might ask?** Yes, there is!
15
17
16
18
1. The installation directory differs:
17
-
* Apple Java 1.5/1.6: `/System/Library/Java/JavaVirtualMachines/`
19
+
* 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...
24
+
* This is because Apple's `JavaApplicationStub` only works for Apple's Java and their *style* to store Java properties in the `Info.plist` file.
25
+
* 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).
26
+
* Thus you would need the user to know which Java distribution he has installed on their Mac. Not very user friendly...
25
27
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...
28
+
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
29
28
30
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.
31
+
* 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
32
* If Java 7/8 is installed, Apple doesn't accept those java versions as suitable
31
33
* 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
34
* This requires to use the latest [JarBundler](https://github.com/UltraMixer/JarBundler/) version (see below for more details)
33
35
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:
36
+
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.
37
+
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!
38
+
The original script was inspired by [Ian Roberts stackoverflow answer](http://stackoverflow.com/a/17546508/1128689). Thanks, Ian!
35
39
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
40
38
41
How the script works
39
42
--------------------
40
43
41
-
You don't need a native `JavaApplicationStub` file anymore. The Shell script needs to be executable – that's all.
44
+
You don't need a native `JavaApplicationStub` file anymore. The Bash script needs to be executable – that's all.
42
45
43
-
The script reads JVM properties from `Info.plist` regardless of whether it's Apple or Oracle flavour and feeds it to a commandline `java` call like the following:
46
+
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:
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.
71
+
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.
67
72
68
-
The WorkingDirectory is either retrieved from Apple's Plist key `Java/WorkingDirectory` or set to the JavaRoot directory within the app bundle.
73
+
The *WorkingDirectory* is either retrieved from Apple's Plist key `Java/WorkingDirectory` or set to the JavaRoot directory within the app bundle.
69
74
70
-
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*.
75
+
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*.
71
76
72
77
There is some *foo* happening to determine which Java versions are installed – here's the list in which order system properties are checked:
73
78
@@ -78,14 +83,16 @@ There is some *foo* happening to determine which Java versions are installed –
* Symlink for old Apple Java: `/Library/Java/Home/bin/java`
81
-
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
86
+
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
82
87
* if multiple matching JVM's are found, the script will pick the latest (highest version number)
88
+
* 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.
83
89
84
-
If none of these could be found or executed the script shows an applescript error dialog saying that Java needs to be installed:
90
+
If none of these can be found or executed the script shows an AppleScript error dialog saying that Java needs to be installed:
85
91
86
92

87
93
88
-
Messages are localized and displayed either in English (Default), French or German. Language contributions are very welcome!
94
+
Messages are **localized** and displayed either in English (Default), French, German or Chinese. Language contributions are very welcome! Thank you!
95
+
89
96
90
97
What you need to do
91
98
-------------------
@@ -117,7 +124,7 @@ Then place the `universalJavaApplicationStub` from this repo in your build resou
117
124
</jarbundler>
118
125
```
119
126
120
-
The ANT task will care about the rest...
127
+
The ANT task will take care of all the rest... But of course you can specify more options. Please check the JarBundler docs.
121
128
122
129
You should get a fully functional Mac Application Bundle working with both Java distributions from Apple and Oracle and all Mac OS X versions.
123
130
@@ -134,20 +141,48 @@ Just place the `universalJavaApplicationStub` from this repo in your build resou
134
141
</appbundler>
135
142
```
136
143
137
-
138
-
The ANT task will care about the rest...
144
+
The ANT task will take care of all the rest... But of course you can specify more options. Please check the Appbundler docs.
139
145
140
146
You should get a fully functional Mac Application Bundle working with both Java distributions from Apple and Oracle and all Mac OS X versions.
|**Main Class Arguments**|`:Java(X):Arguments`|`:JVMArguments`|
165
+
166
+
167
+
Logging
168
+
-------
169
+
170
+
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*:
171
+
172
+

173
+
174
+
Log data includes debug information of the JVM search strategy, App name, language, selected JVM, WorkingDirectory and exec call.
175
+
176
+
143
177
Missing Features
144
178
----------------
145
179
146
180
At the moment, there's no support for
147
181
* required JVM architecture (like `x86_64`, etc.)
182
+
* prefer JDK over JRE or vice versa
148
183
149
184
150
185
License
151
186
-------
152
187
153
-
*universalJavaApplicationStub* is released under the MIT License.
188
+
*universalJavaApplicationStub* is released under the [MIT License](https://github.com/tofi86/universalJavaApplicationStub/blob/master/LICENSE).
0 commit comments