1
votes

I have a serious Problem while migrating a macos App from Java 6 to Java 8. Since it is deployed on mac, the program was using com.apple.eawt.ApplicationAdapter which is deprecated and replaced by com.apple.eawt.XYHandler.

So far so good, I can launch my application from within Eclipse (which has the compiler compliance level set to 1.8, the JRE is set to Java SE 8).

I have then a script which calls javac, puts the compiled jars into an .app bundle, writes an Info.plist and so on. The Java JVMVersion is set to 1.8+ .This also works, so far.

When I try to launch the app, it tells no suitable version of Java 1.8+ is available

[JavaAppLauncher] Requested [1.8+], launching in [(null)] instead.

[JavaAppLauncher Error] unable to find a version of Java to launch

I tried all possible options for the JVMVersion (1.8*, 1.8.0_181, 1.7+, 1.6+) and the last one is the only one which starts. Of course later it crashes 'cause Java6 doesn't implement the XYHandlerbut the ApplicationAdapter.

If I launch the main class from command line it starts but it crashes afterwards because of this:

dyld: Symbol not found: _CTFontCopyDefaultCascadeListForLanguages Referenced from: /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre/lib/libawt_lwawt.dylib Expected in: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices

Which is weird, since my research on the topic tells that _CTFontCopyDefaultCascadeListForLanguages should be available in Java8.

By the way, the result of java -version is

java version "1.8.0_181"

Java(TM) SE Runtime Environment (build 1.8.0_181-b13)

Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

and following jdks are installed

1.8.0_181, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home

1.8.0_60, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home

1.7.0_80, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home

1.6.0_65-b14-468, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

1.6.0_65-b14-468, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

So I guess the problem is in the way how the OS launches the app. What am I doing wrong?

1
_CTFontCopyDefaultCascadeListForLanguages should be available in Java8 This is not a Java but a OS issue, on another computer with newer OS the application runs perfectly when launched from console, but still tells there is no suitable Java available when launching the app-bundlenhaggen

1 Answers

2
votes

Found the solution to the problem. Since the migration from Apple's java 6 to Oracle's java 8 JDK, some setting got lost and the System does not know, that the JVM is able to run bundled applications.

The info.plist of the jvm itself needs to be modified in order to tell the OS, that the Java 8 JVM is suitable for running the app.

This website describes how to modify the info.plist file and there is even a Script that does it for you.

In brief, the changes that have to be done are following. The file /Library/Java/JavaVirtualMachines/jdk_version_info_goes_here.jdk/Contents/Info.plist has to be changed from this

<key>JavaVM</key>
  <dict>
    <key>JVMCapabilities</key>
      <array>
        <string>CommandLine</string>
      </array> ...

to this

<key>JavaVM</key>
  <dict>
    <key>JVMCapabilities</key>
      <array>
        <string>BundledApp</string>
        <string>CommandLine</string>
        <string>JNI</string>
      </array> ...