Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 46b1f67

Browse files
authored
Release version 3.0.0 (PR #60)
Merge pull request #60 from tofi86/develop
2 parents f9011dd + 4eea734 commit 46b1f67

File tree

6 files changed

+921
-516
lines changed

6 files changed

+921
-516
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
ChangeLog
22
---------
33

4+
### v3.0.0 (2018-02-25)
5+
* Completeley overhauled algorithm for JVM detection (JRE and JDK)
6+
* JDK has no longer precedence over JRE
7+
* All Java Virtual Machines on the system are taken into account
8+
* See Readme section 'How the script works' for more details
9+
* NEW special syntax in Plist key `JVMVersion` to specify a maximum JVM version requirement in addition to the minimum requirement.
10+
* See issue #51 for examples
11+
* Support `JVMVersion` also in Oracle PList style (#59)
12+
* Implemented logging to `syslog` facility which can be viewed via `Console.app` (#49)
13+
* Translation of messages to Chinese (PR #55, Thanks to @acely for his contribution)
14+
* Added a table with 'Supported PList keys' to the Readme file
15+
* Refactoring of functions, bash syntax, etc... (#46, #50, #56)
16+
* Bugfix: pass JVM options with spaces correctly to the java exec call (#14)
17+
* Bugfixes: better handling of MainClass arguments with spaces (#57, #58)
18+
* Bugfixes: issues #47, #48, #52
19+
420
### v2.1.0 (2017-07-28)
521
* Support for Java 9 which introduces a new version number schema (fixes #43)
622

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Tobias Fischer
3+
Copyright (c) 2014-2018 Tobias Fischer
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 67 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,78 @@
11
universalJavaApplicationStub
2-
=====================
2+
============================
33

44
[![Current release](https://img.shields.io/github/release/tofi86/universalJavaApplicationStub.svg)](https://github.com/tofi86/universalJavaApplicationStub/releases) [![Join the chat at https://gitter.im/tofi86/universalJavaApplicationStub](https://badges.gitter.im/tofi86/universalJavaApplicationStub.svg)](https://gitter.im/tofi86/universalJavaApplicationStub?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
55

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.
79

810

911
Why
1012
---
1113

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.
1315

1416
**Is there some difference, you might ask?** Yes, there is!
1517

1618
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`
1820
* Oracle JRE 1.7/1.8: `/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/`
1921
* Oracle JDK 1.7/1.8: `/System/Library/Java/JavaVirtualMachines/`
2022

2123
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...
2527

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...
2729

2830
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.
3032
* If Java 7/8 is installed, Apple doesn't accept those java versions as suitable
3133
* 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.
3234
* This requires to use the latest [JarBundler](https://github.com/UltraMixer/JarBundler/) version (see below for more details)
3335

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!
3539

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!
3740

3841
How the script works
3942
--------------------
4043

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.
4245

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:
4447

4548
```Bash
4649
# execute Java and set
47-
# - classpath
48-
# - dock icon
49-
# - application name
50-
# - JVM options
51-
# - JVM default options
52-
# - main class
53-
# - JVM arguments
54-
exec "$JAVACMD" \
50+
# - classpath
51+
# - splash image
52+
# - dock icon
53+
# - app name
54+
# - JVM options
55+
# - JVM default options
56+
# - main class
57+
# - main arguments
58+
# - passthru arguments
59+
exec "${JAVACMD}" \
5560
-cp "${JVMClassPath}" \
5661
-splash:"${ResourcesFolder}/${JVMSplashFile}" \
5762
-Xdock:icon="${ResourcesFolder}/${CFBundleIconFile}" \
5863
-Xdock:name="${CFBundleName}" \
5964
${JVMOptions:+$JVMOptions }\
6065
${JVMDefaultOptions:+$JVMDefaultOptions }\
6166
${JVMMainClass}\
62-
${JVMArguments:+ $JVMArguments}\
67+
${MainArgs:+ $MainArgs}\
6368
${ArgsPassthru:+ $ArgsPassthru}
6469
```
6570

66-
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.
6772

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.
6974

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*.
7176

7277
There is some *foo* happening to determine which Java versions are installed – here's the list in which order system properties are checked:
7378

@@ -78,14 +83,16 @@ There is some *foo* happening to determine which Java versions are installed –
7883
* `/usr/libexec/java_home` symlinks
7984
* Oracle's JRE Plugin: `/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java`
8085
* 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
8287
* 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.
8389

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:
8591

8692
![Error Dialog No Java Found](/docs/java-error.png?raw=true)
8793

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+
8996

9097
What you need to do
9198
-------------------
@@ -117,7 +124,7 @@ Then place the `universalJavaApplicationStub` from this repo in your build resou
117124
</jarbundler>
118125
```
119126

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.
121128

122129
You should get a fully functional Mac Application Bundle working with both Java distributions from Apple and Oracle and all Mac OS X versions.
123130

@@ -134,20 +141,48 @@ Just place the `universalJavaApplicationStub` from this repo in your build resou
134141
</appbundler>
135142
```
136143

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.
139145

140146
You should get a fully functional Mac Application Bundle working with both Java distributions from Apple and Oracle and all Mac OS X versions.
141147

142148

149+
Supported PList keys
150+
--------------------
151+
152+
| Function | Apple PList key | Oracle PList key |
153+
|---------------------------------|------------------------|-----------------------|
154+
| **App Name** (Dock Name) | `:CFBundleName` | `:CFBundleName` |
155+
| **App Icon** (Dock Icon) | `:CFBundleIconFile` | `:CFBundleIconFile` |
156+
| **Working Directory** | `:Java(X):WorkingDirectory`<br/>fallback to `name.app/`<br/>support for variables `$APP_PACKAGE`, `$JAVAROOT`, `$USER_HOME` | *not supported*<br/>default: `name.app/Contents/Java/` |
157+
| **Java Min/Max[*](https://github.com/tofi86/universalJavaApplicationStub/issues/51) Version Requirement** | `:Java(X):JVMVersion` | `:JVMVersion` |
158+
| **Java ClassPath** (`-cp …`) | `:Java(X):ClassPath` | `:JVMClassPath` |
159+
| **Java Main Class** | `:Java(X):MainClass` | `:JVMMainClassName` |
160+
| **Splash Image** (`-splash:…`) | `:Java(X):SplashFile` | `:JVMSplashFile` |
161+
| **Java VM Options** (`-X…`) | `:Java(X):VMOptions` | `:JVMDefaultOptions` |
162+
| **`-XstartOnFirstThread`** [*](https://stackoverflow.com/questions/28149634/what-does-the-xstartonfirstthread-vm-argument-do-mean) | `:Java(X):StartOnMainThread` | *not supported* |
163+
| **Java Properties** (`-D…`) | `:Java(X):Properties` | `:JVMOptions` |
164+
| **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+
![Example log data in Console.app](/docs/ConsoleAppLogging.png?raw=true)
173+
174+
Log data includes debug information of the JVM search strategy, App name, language, selected JVM, WorkingDirectory and exec call.
175+
176+
143177
Missing Features
144178
----------------
145179

146180
At the moment, there's no support for
147181
* required JVM architecture (like `x86_64`, etc.)
182+
* prefer JDK over JRE or vice versa
148183

149184

150185
License
151186
-------
152187

153-
*universalJavaApplicationStub* is released under the MIT License.
188+
*universalJavaApplicationStub* is released under the [MIT License](https://github.com/tofi86/universalJavaApplicationStub/blob/master/LICENSE).

docs/ConsoleAppLogging.png

337 KB
Loading

0 commit comments

Comments
 (0)