Bug 152644 - Java path not found nor selectable after upgrade
Summary: Java path not found nor selectable after upgrade
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.4.3.2 release
Hardware: ARM macOS (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-22 11:37 UTC by Daniele
Modified: 2023-01-25 20:48 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Empty advanced java options (122.77 KB, image/png)
2022-12-22 11:37 UTC, Daniele
Details
Java JDK found (858.69 KB, image/png)
2023-01-06 04:32 UTC, Sierk Bornemann
Details
Java JDK found and selected (868.10 KB, image/png)
2023-01-06 04:33 UTC, Sierk Bornemann
Details
Location of java on disk (59.59 KB, image/png)
2023-01-07 18:19 UTC, Daniele
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniele 2022-12-22 11:37:59 UTC
Created attachment 184313 [details]
Empty advanced java options

Hi,
after upgrading to this release Java is not seen upon installation and not even when the path is given in preferences advanced add.

I get the error message upon Libreoffice start: LibreOffice requires a Java runtime environment (JRE) to perform this task. The selected JRE is defective. Please select another version or install a new JRE and select it under LibreOffice - Preferences - LibreOffice - Advanced.

And I have three Java version installed in Mac Mini Macintosh HD Library Java Javavirtualmachines
jdk-18.0.2jdk
temurin17.jdk
zulu-18.jre



Version: 7.4.3.2 / LibreOffice Community
Build ID: 1048a8393ae2eeec98dff31b5c133c5f1d08b890
CPU threads: 8; OS: Mac OS X 12.6; UI render: default; VCL: osx
Locale: it-IT (en_IT.UTF-8); UI: en-US
Calc: threaded
Comment 1 Sierk Bornemann 2023-01-06 04:31:13 UTC
I cannot confirm the issue (however, I only have installed 1 JDK (Oracle JDK) rather than multiple JDKs, installed in the OS's intended default location below /Library/Java/JavaVirtualMachines/), see attached screenshots.

Version: 7.5.0.1 (AARCH64) / LibreOffice Community
Build ID: 77cd3d7ad4445740a0c6cf977992dafd8ebad8df
CPU threads: 10; OS: Mac OS X 13.1; UI render: Skia/Metal; VCL: osx
Locale: de-DE (de_DE.UTF-8); UI: de-DE
Calc: threaded

% /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home

% /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
    19.0.1 (arm64) "Oracle Corporation" - "Java SE 19.0.1" /Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home


Manpage java_home:
% man java_home


@Daniele: Where are your Java JDKs (a JDK contains a JRE) installed? In the default location, Apple has intended for JDKs to be installed in macOS (means: below /Library/Java/JavaVirtualMachines/)?

And: do you have set the environment variable JAVA_HOME in your ~/.bash_profile, ~/.zprofile or ~/.profile to set, which one of your several JDK-installations should be taken and preferred (instead the first one, which is found by java_home per default, if no further specific option is given)?

For instance (examples):

## JAVA_HOME
export JAVA_HOME=$(/usr/libexec/java_home)

or

# Most recent stable Java VM: 19 VM
# Either take/print a 19 VM or, if failing, take/print nothing, if neither is found.
export JAVA_HOME=$(/usr/libexec/java_home -F -v 19)

or

# Either take/print a 19 VM or, if failing, take/print a 18 VM or nothing, if neither is found.
export JAVA_HOME=$(/usr/libexec/java_home -F -v 19 || \
                  /usr/libexec/java_home -F -v 18)

or

# Either take/print a 19 VM or, if failing, take/print a 18 VM or, if failing, take/print a 17 VM or nothing if neither is found.
export JAVA_HOME=$(/usr/libexec/java_home -F -v 19 || \
                  /usr/libexec/java_home -F -v 18 || \
                  /usr/libexec/java_home -F -v 17)



See also:

Apple Developer: Technical Q&A QA1170: Important Java Directories on Mac OS X –> Section JAVA Home
https://developer.apple.com/library/archive/qa/qa1170/_index.html#//apple_ref/doc/uid/DTS10001702-CH1-SECTION1

Apple Developer Forum: How does /usr/libexec/java_home know where are my jdks are installed?
https://developer.apple.com/forums/thread/681025

Mykyong.com, January 19, 2021: How to Set $JAVA_HOME environment variable on macOS
https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/
Comment 2 Sierk Bornemann 2023-01-06 04:32:34 UTC
Created attachment 184500 [details]
Java JDK found
Comment 3 Sierk Bornemann 2023-01-06 04:33:06 UTC
Created attachment 184501 [details]
Java JDK found and selected
Comment 4 Alex Thurgood 2023-01-06 08:40:11 UTC
@Daniele : in addition to Sierk's comments, your JDK needs to match the build architecture for the version of LO.

If your Mac has a x86_64 (Intel and compatible) processor, then you should be using x86_64 versions of the JDK.

If your Mac has an Arm processor, then you should be using an Arm version of LO with an aarch (aarch64) version of the JDK. You can't mix and match the two types.
Comment 5 Alex Thurgood 2023-01-06 08:56:17 UTC
BTW, I couldn't get any Oracle JRE recognized by LO, even with correct architecture matching.
Comment 6 Alex Thurgood 2023-01-06 09:21:21 UTC
There is an additional complication in that not all versions of a JDK aarch64 are recognized either, for example :

Version: 7.4.3.2 / LibreOffice Community
Build ID: 1048a8393ae2eeec98dff31b5c133c5f1d08b890
CPU threads: 8; OS: Mac OS X 13.0.1; UI render: Skia/Raster; VCL: osx
Locale: fr-FR (fr_FR.UTF-8); UI: fr-FR
Calc: threaded

finds the following two JDKs :

Temurin
file /Library/Java/JavaVirtualMachines/temurin-18.jdk/Contents/Home/bin/java
/Library/Java/JavaVirtualMachines/temurin-18.jdk/Contents/Home/bin/java: Mach-O 64-bit executable arm64

and also :

Oracle
file /Library/Java/JavaVirtualMachines/jdk-17_aarch64.jdk/Contents/Home/bin/java
/Library/Java/JavaVirtualMachines/jdk-17_aarch64.jdk/Contents/Home/bin/java: Mach-O 64-bit executable arm64

but it won't recognize:

liberica-jdk-16-full.jdk (aarch64)
or
zulu-17.jdk (aarch64).
Comment 7 Daniele 2023-01-07 08:17:48 UTC
Hi @Sierk Bornemann,

thank you for following up.

My Java VM are in Macintosh HD/Library/Java/JavaVirtualMachines/

I think that they previously were in Macintosh HD/Users/USERA/Library/Java/JavaVirtualMachines/

because it took me a long time to find them, but I cannot be sure. Do not know either when/how they were moved (not by me at any rate). Maybe when I moved to Monterey?

as to your second question: "And: do you have set the environment variable... etc." I am really not familiar with these things. All I do is go to https://adoptium.net/temurin/releases/ 


choose the right release and then install it. But as 

@Alex Thurgood pointed out, I might have chosen the wrong one. So I am choosing now the aarch64. Downloaded and installed it. Deleted the other two.

I closed LO and re-opened it.

Got the same error message.

Went manually to (tried both clicking on add and class path) /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/

LO will not see the java (they are all greyed out) and I get the error message: The folder you selected does not contain a Java runtime environment.
Please select a different folder. 

I hope this helps.

I do not know if this is possible: but it would be great if LO worked "out of the box": the average user (who will at the most download and install LO without going to Preferences) would highly benefit from it! Maybe an error message from LO pointing to a java download page (and instructions on what to do)? Thanks!
Comment 8 Alex Thurgood 2023-01-07 15:54:26 UTC
(In reply to Daniele from comment #7)
> Hi @Sierk Bornemann,
> 
> thank you for following up.
> 
> My Java VM are in Macintosh HD/Library/Java/JavaVirtualMachines/
> 
> I think that they previously were in Macintosh
> HD/Users/USERA/Library/Java/JavaVirtualMachines/
> 
> because it took me a long time to find them, but I cannot be sure. Do not
> know either when/how they were moved (not by me at any rate). Maybe when I
> moved to Monterey?
> 
> as to your second question: "And: do you have set the environment
> variable... etc." I am really not familiar with these things. All I do is go
> to https://adoptium.net/temurin/releases/ 
> 
> 
> choose the right release and then install it. But as 
> 
> @Alex Thurgood pointed out, I might have chosen the wrong one. So I am
> choosing now the aarch64. Downloaded and installed it. Deleted the other two.
> 
> I closed LO and re-opened it.
> 
> Got the same error message.
> 
> Went manually to (tried both clicking on add and class path)
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/
> 

Theoretically, you shouldn't need to point it to the /bin directory, just the /temurin-17.jdk/ folder. 

However, it might well be that temurin-17.jdk isn't recognized. As I said, not all versions are recognized. 

> I do not know if this is possible: but it would be great if LO worked "out
> of the box": the average user (who will at the most download and install LO
> without going to Preferences) would highly benefit from it! Maybe an error
> message from LO pointing to a java download page (and instructions on what
> to do)? Thanks!


I would love for this to be possible, but the whole sorry Java recognition business has been a long standing debacle due to the fact that Apple and Oracle fell out, and the LO project has been trying to play keep up for functionality that it has wanted to make entirely optional and not yet succeeded without losing key functionality, well, because people actually still use Java on a day-to-day basis with their office productivity suite.
Comment 9 Alex Thurgood 2023-01-07 15:56:24 UTC
(In reply to Daniele from comment #7)
> Hi @Sierk Bornemann,
> 
> thank you for following up.
> 
> My Java VM are in Macintosh HD/Library/Java/JavaVirtualMachines/
> 
> got the same error message.
> 
> Went manually to (tried both clicking on add and class path)
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/
> 

Why aren't you using temurin-18.jdk?
Comment 10 Daniele 2023-01-07 16:15:37 UTC
Hi @Alex, thank you for your detailed answers also on the history of Java.

I installed temurin-18.jdk, and from LO preferences advanced pointed to 

Macintosh
> HD/Users/USERA/Library/Java/JavaVirtualMachines/temurin-18.jdk


but got the same error message.

The previous version of LO found it without any issue, but somehow now that it is higher up in the file system it won't fetch it.

I am also happy to use any other java version that works.
Comment 11 Alex Thurgood 2023-01-07 16:40:22 UTC
(In reply to Daniele from comment #10)

Hi @Daniele,

> Macintosh
> > HD/Users/USERA/Library/Java/JavaVirtualMachines/temurin-18.jdk
> 
> 
> but got the same error message.
> 


Ah, pretty certain that that's the wrong place to put your JDK in.

It needs to go in the system /Library/ folder (and not the user Library folder) under the corresponding /JavaVirtualMachines/ directory.
Comment 12 Daniele 2023-01-07 18:19:30 UTC
Created attachment 184518 [details]
Location of java on disk
Comment 13 Daniele 2023-01-07 18:19:51 UTC
@Alex, sorry I copied from a previous message hastily and wrote it wrongly. This is the path it was installed to: Macintosh HD/Library/Java/JavaVirtualMachines
I am also attaching a screenshot of the details
Comment 14 Alex Thurgood 2023-01-07 19:48:05 UTC
(In reply to Daniele from comment #13)
> @Alex, sorry I copied from a previous message hastily and wrote it wrongly.
> This is the path it was installed to: Macintosh
> HD/Library/Java/JavaVirtualMachines
> I am also attaching a screenshot of the details

@Daniele, thanks for the update!
Very strange that LO doesn't recognize the JDK there. That's exactly where all of mine are.

The only other thing I can think of would be a permissions problem, possibly due to a recent macOS update? Sorry I can't be of more help.
Comment 15 Daniele 2023-01-25 09:01:28 UTC
Hi @Alex and @Sierk Borneman,

An update: I updated Mac Os to the latest Ventura 13.2 then reinstalled Libreoffice (see version below), deleted both instances of Java and reinstalled Java as well from https://adoptium.net/temurin/releases/ .

Now everything works fine. 

Thank you so much for your help.


Version: 7.4.4.2 / LibreOffice Community
Build ID: 85569322deea74ec9134968a29af2df5663baa21
CPU threads: 8; OS: Mac OS X 13.2; UI render: default; VCL: osx
Locale: it-IT (en_IT.UTF-8); UI: en-US
Calc: threaded