Installation problem M1 apple silicon Java2 cannot be instantiated - languagetool

Hi, after upgrading to 7.2.6.2, languagetool extension stopped working, so I tried removing it and reinstalling it.

I get this message during installation:

ImplementationRegistration::registerImplementation() - The service com.sun.star.loader.Java2 cannot be instantiated

I had a look at a number of discussions on this topic around the web and installed a number of different Java flavors:

jdk-14.0.2_osx-x64_bin
jdk-17.0.2_macos-aarch64_bin
jre-8u321-macosx-x64
JavaForOSX (I could not install this one since I get the message that a more recent version has been installed)

Languagetool version is the latest: LanguageTool-5.7, but also tried to downgrade to 5.6, 5.4, with no improvement.
Also tried reinstalling LO after having installed the Java packages. No improvement.

This is what my advanced settings in LO look like
Schermata 2022-04-02 alle 09.35.36

And this is what the Extension manager looks like:
Schermata 2022-04-02 alle 09.37.00

Any help is welcome!

Version: 7.2.6.2 / LibreOffice Community
Build ID: b0ec3a565991f7569a5a7f5d24fed7f52653d754
CPU threads: 8; OS: Mac OS X 12.2.1; UI render: default; VCL: osx
Locale: it-IT (it.UTF-8); UI: en-US
Calc: threaded

Have you seen the following pages that LT offers as links from https://extensions.libreoffice.org/en/extensions/show/languagetool?

https://languagetooler.freshdesk.com/en/support/home

and

https://languagetooler.freshdesk.com/en/support/solutions/articles/44002037684-mac-specific-issues

1 Like

Thank you @BigRAl I actually followed those instructions and installed the latest Java for Mac + JavaForOSX (but this last one will not install since I get the message that a more recent version has been installed). All that before writing the issue here. The problem remains.

My comment will not solve your real problem. I just want to point out something that I noticed in your question. If I understand you correctly, you are using a Mac with an Apple M1 processor. If this is the case, then you should only use JDK versions suitable for Apple Silicon.

jdk-17.0.2_macos-aarch64_bin – Current Java 17 LTS version for Apple Silicon (AArch64) Mac computers; you should use that.
jdk-14.0.2_osx-x64_bin – Obsolete and unsupported Java 14 non-LTS version for Intel-based (x64) Mac computers; you should remove it.
jre-8u321-macosx-x64 – Current Java Runtime Environment (JRE) for Intel-based (x64) Mac computers; but it doesn’t matter, even Intel-based Macs should require a JDK on macOS, not a JRE; you should remove this one as well.
Java for OS X – I hardly think your recent Mac needs this. You should remove it. As the “OS X” implies, it was meant for Apple operating system versions 10.x. It installs the deprecated Java 6 runtime for macOS 10.13 High Sierra, macOS 10.12 Sierra, macOS 10.11 El Capitan, macOS 10.10 Yosemite, macOS 10.9 Mavericks, macOS 10.8 Mountain Lion, and macOS 10.7 Lion. With macOS Monterey (12.2.1) you are using “Mac OS XII”, if you will, no matter what the LibreOffice version notes say.

You write that the LanguageTool extension worked until you updated LibreOffice to version 7.2.6.2. So it still worked with LibreOffice 7.2.5? Which Java version did you use until then?

Thank you @Piscatorius for taking the time to look at this issue. I downloaded this tool https://www.java.com/en/download/uninstalltool.jsp to look for and uninstall Java versions on my computer, I let it run, uninstalled what was there (it did not say what it was). Then I installed jdk-17.0.2_macos-aarch64_bin, uninstalled LanguageTool-5.7 and reinstalled it again.

I get the same error message.

As for your question,

Which Java version did you use until then?

I do not know, unfortunately, I did not keep track nor did a backup image, just went ahead and upgraded.

Are you using LibreOffice for Apple Silicon (download page), or for Intel architecture? (You provided the full version info in the question, it’s just me not aware if there’s some indication about the platform in out macOS builds.)

I know that at some point, MS builds of JDK were functional with LO for Apple Silicon. (@cloph may advise better on current state of affairs.)

Thank you I downloaded Apple Silicon: LibreOffice_7.2.6_MacOS_aarch64.dmg @mikekaganski do you have any experience, o does someone have it with any working MS build of JDK? And in this case, could point me to the right buid? Thanks!

Unfortunately I myself have no experience (I don’t even have a mac), and only followed our development related to Silicon. I shared what I learned (in theory) then, and pinged @cloph in the hope he may share his expertise here. Of course, I hope others could also help you.

Yet, I’d suggest you to simply try (one after the other) installing the two available builds for M1 (my link above leads to a page that has a Download link; and I see only a pkg for JDK14, and a pkg for JDK17). Installing one, rebooting, testing if Java options page in LO shows the JDK, then removing and testing the other, would be what I’d try.

Also it’s possible that we only fixed Java recognition on M1 in LibreOffice 7.3. (Again, I don’t know for sure, just speculating.)

I don’t know the Java uninstallation tool you mentioned. I have always uninstalled outdated Java versions manually in the way described by Oracle. On the Java Downloads page, not only are the different Java versions available for download, but you will also find all the information regarding the steps required to uninstall each version. For each version, there is a link called “Installation Instructions”. And as strange as it sounds, you can also find the respective uninstall instructions under this very link. This way, you will not only find out which Java versions are (still) installed on your Mac, but also where on the system they are located. In the installation instructions, you will also find information on how to easily determine the default JDK version using the terminal.

Thank you @mikekaganski and @Piscatorius, actually upgrading to 7.3 did the trick. Two Java installations (see image) are recognized and Languagetool works fine. So I am marking @mikekaganski answer as correct.

Schermata 2022-04-04 alle 20.46.43

@Piscatorius, as for the Java Installation Instructions are concerned, they look pretty easy and I was able to see that I have five Java versions (jdk-14.0.1.jdk jdk-14.0.2.jdk jdk-17.0.2.jdk temurin-17.jdk zulu-18.jre) of which I need only one, the jdk-17.0.2.jdk (See image); however I tried using the command $ rm -rf jdk-14.0.1.jdk suggested in the instructions to cancel other Java versions, but I get the message Permission denied. Any ideas on how to proceed? I could of course delete the directories manually from Finder but is that what one is meant to do?

If you have any suggestions, I’ll be grateful.

1 Like

Yes, exactly, as simple as it may seem, but that’s what I used to do when I was using Oracle’s JDKs exclusively. Since installing a newer Java version from Oracle does not overwrite the previous version, I always had to remove the old version myself. And I preferred to do that via the Finder; you don’t really need the rm command for that. Since you want to remove multiple JDKs from different vendors, this is probably the better choice anyway.
Go to /Library/Java/JavaVirtualMachines. Now select the folder with the JDK you want to remove with a right mouse click and then click Move to Trash. The operating system will now ask you for your user password. After entering the correct password, the entire folder of the JDK you want to remove will be moved to the Trash. That’s it.
Another tip: Personally, I now use the JDKs from Adoptium. Among other things, they have the advantage that when you install a newer version of a JDK, the previous version gets overwritten. This saves me from having to remove the outdated version.

That was really helpful @Piscatorius! I did as you suggested, and the other JDKs are gone. I kept the JDK from Adoptium. May I ask how you know when it’s time to update JDK Temurin from Adoptium?

1 Like

The respective Temurin release dates can be found in the Release Roadmap, which are published on the Adoptium website under Temurin Support. The next release is scheduled for April 19, 2022.

I had this problem and what fixed it for me was installing the Apple silicone version of LO instead of the apple intel version.