tofi86 / universalJavaApplicationStub

universalJavaApplicationStub - an alternative Application launcher script for Java based macOS Apps that works with both Apple's and Oracle's PList format and supports the old Apple Java 6 as well as all the latest Oracle/OpenJDK/Adopt/Corretto JRE's/JDK's. Plus it supports drag&drop to the Dock icon 🎉
MIT License
354 stars 168 forks source link

issues when bundling jdk with app and setting JAVA_HOME using LSEnvironment #86

Closed Abu-Abdullah closed 3 years ago

Abu-Abdullah commented 4 years ago

I'm submitting a…

Short description of the issue/suggestion:

Setting JAVA_HOME is not working using LSEnvironment and it gives the following errors:

default 17:26:34.618408+0400    syslog  [1000][Error Reading File: /Users/oracle/Desktop/Mawareth.app/Contents/Info.plist] [PlistStyle] Oracle
default 17:26:34.655566+0400    syslog  [1000][Error Reading File: /Users/oracle/Desktop/Mawareth.app/Contents/Info.plist] [JavaRequirement] JVM minimum version: Error Reading File: /Users/oracle/Desktop/Mawareth.app/Contents/Info.plist
default 17:26:34.660862+0400    syslog  [1000][Error Reading File: /Users/oracle/Desktop/Mawareth.app/Contents/Info.plist] [JavaRequirement] JVM maximum version:
default 17:26:34.679730+0400    syslog  [1000][Error Reading File: /Users/oracle/Desktop/Mawareth.app/Contents/Info.plist] [Language] en_AE
default 17:26:34.691976+0400    syslog  [1000][Error Reading File: /Users/oracle/Desktop/Mawareth.app/Contents/Info.plist] [JavaSearch] Checking for $JAVA_HOME ...
default 17:26:34.697545+0400    syslog  [1000][Error Reading File: /Users/oracle/Desktop/Mawareth.app/Contents/Info.plist] [JavaSearch] ... didn't found JAVA_HOME
default 17:26:34.703058+0400    syslog  [1000][Error Reading File: /Users/oracle/Desktop/Mawareth.app/Contents/Info.plist] [JavaSearch] Checking for JavaVirtualMachines on the system ...
default 17:26:34.710664+0400    syslog  [1000][Error Reading File: /Users/oracle/Desktop/Mawareth.app/Contents/Info.plist] [EXIT 4] The syntax of the required Java version is invalid: Error Reading File: /Users/oracle/Desktop/Mawareth.app/Contents/Info.plist
Please contact the App developer.

Steps to reproduce the issue/enhancement: Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>LSMinimumSystemVersion</key>
        <string>10.8.0</string>
        <key>CFBundleExecutable</key>
        <string>universalJavaApplicationStub</string>
        <key>CFBundleName</key>
        <string>Mawareth</string>
        <key>CFBundleVersion</key>
        <string>2.7</string>
        <key>CFBundleIconFile</key>
        <string>icon.icns</string>
        <key>CFBundleIdentifier</key>
        <string>Mawareth</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>7.0</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>1.0</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>NSHumanReadableCopyright</key>
        <string>©2020, Maknoon Apps</string>
        <key>JVMRuntime</key>
        <string>jdk.jdk</string>
        <key>JVMMainClassName</key>
        <string>com.maknoon.Mawareth</string>
        <key>JVMAppClasspath</key>
        <string>.:lib/filters-2.0.235.jar:lib/java-image-scaling-0.8.6.jar:lib/jericho-html-3.3.jar:lib/rsyntaxtextarea-2.6.1.jar:lib/slf4j-api-1.7.27.jar:lib/svg-salamander-1.1.2.2.jar:lib/weblaf-core-1.2.12.jar:lib/weblaf-ui-1.2.12.jar:lib/xstream-1.4.9.jar</string>
        <key>JVMMainJarName</key>
        <string>Mawareth.jar</string>
        <key>JVMPreferencesID</key>
        <string>com/maknoon/Mawareth</string>
        <key>LSEnvironment</key>
        <dict>
            <key>JAVA_HOME</key>
            <string>Contents/PlugIns/jdk.jdk</string>
        <dict>
        <key>NSHighResolutionCapable</key>
        <string>true</string>
    </dict>
</plist>

I'm bundling bellsoft jre for macos bellsoft-jre14.0.1+8-macos-amd64.zip

Please tell us about your environment:

tofi86 commented 4 years ago

Hi,

first of all, you should make sure that your Info.plist XML file is well-formed:

<dict>
    <key>JAVA_HOME</key>
    <string>Contents/PlugIns/jdk.jdk</string>
<dict>

What is meant to be a closing tag isn't a closing tag!

Then, second point is regarding the JAVA_HOME value: Is the path Contents/PlugIns/jdk.jdk really the path to the JAVA_HOME directory? Does this folder contain the bin/ directory with the java binary?

When I tried to bundle an oracle JRE once, this was the path I had to use: https://github.com/tofi86/universalJavaApplicationStub/blob/master/README.md#bundle-a-jrejdk-with-your-app

lqlau commented 3 years ago

Hi. I'm testing universalJavaApplicationStub on Big Sur.

I made sure my XML is welled formed in Info.plist:

   `<key>LSEnvironment</key>
<dict>
         <key>JAVA_HOME</key>
         <string>Contents/Resources/Frameworks/amazon-corretto-8.jdk/Contents/Home</string>
</dict>`

But still it doesn't seem that JAVA_HOME environment variable is set as it says 'didn't find JAVA_HOME'. Here's the console sys log output:

default 10:43:48.606618-0800 syslog [6323][universalJavaApplicationStub] [StubDir] /Applications/MyApp.app/Contents/MacOS default 10:43:48.618982-0800 syslog [6323][MyApp] [PlistStyle] Apple default 10:43:48.662591-0800 syslog [6323][MyApp] [JavaRequirement] JVM minimum version: 1.8 default 10:43:48.665935-0800 syslog [6323][MyApp] [JavaRequirement] JVM maximum version: default 10:43:48.678139-0800 syslog [6323][MyApp] [Language] en_CA default 10:43:48.687225-0800 syslog [6323][MyApp] [JavaSearch] Checking for $JAVA_HOME ... default 10:43:48.690421-0800 syslog [6323][MyApp] [JavaSearch] ... didn't found JAVA_HOME default 10:43:48.693876-0800 syslog [6323][MyApp] [JavaSearch] Searching for JavaVirtualMachines on the system ... default 10:43:48.709511-0800 syslog [6323][MyApp] [JavaSearch] ... found 2 JVM's default 10:43:48.723711-0800 syslog [6323][MyApp] [JavaSearch] ... found JVM: 1.8.0_272:/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home/bin/java default 10:43:48.727072-0800 syslog [6323][MyApp] [JavaSearch] ... found JVM: 1.8.0_272:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java

tofi86 commented 3 years ago

@lqlau I improved the logging for JAVA_HOME detection with #100. Maybe this helps.

Closing this as the original author didn't respond to my questions. @Abu-Abdullah please feel free to reopen this issue if needed.