Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sko

macrumors 6502
Original poster
Oct 17, 2009
285
59
Germany
My Adobe products rely on old Java, but I'm not going to install Java 6. There is a workaround to make Java 6 obsolete and to get Adobe accepting newer Java version.

As Java gets updated more or less frequently, I want to automate the few steps needed, basically creating an alias in a specific location and adding something to the Java Info.plist.

And with this last point I have a problem. There's an array within an dictionary, I just don't know how address this. I'm trying with

Code:
do shell script "defaults write " & TargetPath & " JavaVM -dict-add JVMCapabilities -array-add JNI BundledApp" with administrator privileges

but that doesn't work.

I guess it's just some minor syntax issue, but I just don't get it.

Thanks in advance!

Code:
<?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>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleExecutable</key>
        <string>libjli.dylib</string>
        <key>CFBundleGetInfoString</key>
        <string>Java SE 1.8.0_77</string>
        <key>CFBundleIdentifier</key>
        <string>com.oracle.java.8u77.jdk</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>7.0</string>
        <key>CFBundleName</key>
        <string>Java SE 8</string>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
        <string>1.0</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>1.8.0_77</string>
        <key>JavaVM</key>
        <dict>
                <key>JVMCapabilities</key>
                <array>
                        <string>CommandLine</string>
                </array>
                <key>JVMMinimumFrameworkVersion</key>
                <string>13.2.9</string>
                <key>JVMMinimumSystemVersion</key>
                <string>10.6.0</string>
                <key>JVMPlatformVersion</key>
                <string>1.8</string>
                <key>JVMVendor</key>
                <string>Oracle Corporation</string>
                <key>JVMVersion</key>
                <string>1.8.0_77</string>
        </dict>
</dict>
</plist>

Code:
<?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>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleExecutable</key>
        <string>libjli.dylib</string>
        <key>CFBundleGetInfoString</key>
        <string>Java SE 1.8.0_77</string>
        <key>CFBundleIdentifier</key>
        <string>com.oracle.java.8u77.jdk</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>7.0</string>
        <key>CFBundleName</key>
        <string>Java SE 8</string>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
        <string>1.0</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>1.8.0_77</string>
        <key>JavaVM</key>
        <dict>
                <key>JVMCapabilities</key>
                <array>
                    <string>CommandLine</string>
                    <string>JNI</string>
                    <string>BundledApp</string>
                </array>
                <key>JVMMinimumFrameworkVersion</key>
                <string>13.2.9</string>
                <key>JVMMinimumSystemVersion</key>
                <string>10.6.0</string>
                <key>JVMPlatformVersion</key>
                <string>1.8</string>
                <key>JVMVendor</key>
                <string>Oracle Corporation</string>
                <key>JVMVersion</key>
                <string>1.8.0_77</string>
        </dict>
</dict>
</plist>

Code:
on run {input, parameters}

    tell application "System Events"
  
        -- Fetch Folder Path --
  
        set FolderDir to item 1 of input
        set FolderPath to POSIX path of FolderDir
  
        -- Create missing Folders --
  
        try
            set TargetPath to FolderPath & "/Contents/Home/bundle/Libraries"
            do shell script "mkdir -p " & TargetPath with administrator privileges
        end try
  
        -- Create missing Link --
  
        try
            set SourcePath to FolderPath & "/Contents/Home/jre/lib/server/libjvm.dylib"
            set TargetPath to FolderPath & "/Contents/Home/bundle/Libraries/libserver.dylib"
            do shell script "ln -s " & SourcePath & " " & TargetPath with administrator privileges
        end try
  
        -- Add Capabilities to .plist --
  
        try
            set TargetPath to FolderPath & "/Contents/Info.plist"
            do shell script "defaults write " & TargetPath & " JavaVM -dict-add JVMCapabilities -array-add JNI BundledApp" with administrator privileges
            do shell script "chmod 664 " & TargetPath with administrator privileges
        end try
  
    end tell
end run

Automator.png Java Plist Source.png Java Plist Target.png
 
Last edited:
Thanks for the suggestion. I found a simple tutorial by Fotis and ended up using

Code:
            do shell script "/usr/libexec/PlistBuddy -c 'add :JavaVM:JVMCapabilities:1 string JNI' " & TargetPath with administrator privileges
            do shell script "/usr/libexec/PlistBuddy -c 'add :JavaVM:JVMCapabilities:2 string BundledApp' " & TargetPath with administrator privileges

Thanks again!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.