Bug 151545 - LibreOffice 7.4 does not recognize OpenJDK 19 installed with SDKMan
Summary: LibreOffice 7.4 does not recognize OpenJDK 19 installed with SDKMan
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.4.2.3 release
Hardware: Other macOS (All)
: medium normal
Assignee: Stephan Bergmann
URL:
Whiteboard: target:7.5.0 target:7.4.3
Keywords:
: 126162 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-10-15 17:00 UTC by Jose Armando Porto
Modified: 2022-12-05 14:47 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jose Armando Porto 2022-10-15 17:00:52 UTC
Description:
I need to use LibreOffice BASE and receive an error message claiming that I need to install Oracle JAVA JRE.

However I have installed OpenJDK 19 using SDKMan and also made a test installing OracleJDK 19 using SDKMan as well. Regardless of Java Version I install, Libreoffice does not recongnize I have java on my machine up and running. 

Steps to Reproduce:
1. Install SDKMan
2. sdk install java 19-open
3. Install LibreOffice downloading and executing LibreOffice_7.4.2_MacOS_aarch64.dmg
4. Open LibreOffice
5. Choose Base Database on the left menu
6. On the Database Wizard choose to create a new DB using HSQLDB Embedded
7. Click on blue "Next" button on Database Wizard window
8. Click on gray "Finish" button on Database Wizard window
9. Click on blue "Save" using default name and place to create the new DB
10. Appears a message labeled "JRE Required" with contents "LibreOffice requires Oracle's Java Development Kit (JDK) on macOS 10.10 or greater to perform this task. Please install them and restart LibreOffice. https://hub.libreoffice.org/InstallJava/?LOlocale=en-US"
11. Click gray "OK" Button
12. A new error message window pops up with the title "LibreOffice Base" and content is "The connection to the data source "New Database1" could not be established - No Java installation could be found. Please check your Installation."
13. Clicked on the blue "OK" button
14. The dashboard for the "New Database1.odb" is opened however nothing works. 
15. Click on "LibreOffice"=>"Preferences..."==>"Advanced" to show Java options but NO JAVA OPTIONS IS FOUND
16. Click on gray "Add..." button to manually add the JAVA Folder
17. Navigate to the "~/.sdkman/candidates/java/19-open" and click the blue "Open" button
18. An message window pops-up with the title "Warning" and the message "The folder you selected does not contain a Java runtime environment. Please select a different folder"
19. Clicked the blue "Ok" Button and navigate back to the embedded finder window to choose another folder. I tried the following folders with the exactly same results: "~/.sdkman/candidates/java/19-open/bin"; "~/.sdkman/candidates/java/19-open/lib"; ~/.sdkman/candidates/java/19-oracle"; "~/.sdkman/candidates/java/19-oracle/bin"; "~/.sdkman/candidates/java/19-oracle/lib"

Actual Results:
See the "Steps above" since the results are described there

Expected Results:
1) LibreOffice Base automatically recognize my Java installation OR
2) LibreOffice Advanced Options manual Java proceedings recognize SDK installation folders


Reproducible: Always


User Profile Reset: No



Additional Info:
LibreOffice Version Details: 

  Version: 7.4.2.3 / LibreOffice Community
  Build ID: 382eef1f22670f7f4118c8c2dd222ec7ad009daf
  CPU threads: 10; OS: Mac OS X 12.6; UI render: default; VCL: osx
  Locale: en-US (en_BR.UTF-8); UI: en-US
  Calc: threaded


Hardware used: 

  Model Name:	MacBook Pro
  Model Identifier:	MacBookPro18,2
  Chip:	Apple M1 Max
  Total Number of Cores:	10 (8 performance and 2 efficiency)
  Memory:	32 GB
  System Firmware Version:	7459.141.1
  OS Loader Version:	7459.141.1
  Serial Number (system):	XXXXXXXX
  Hardware UUID:	67BC24AF-E347-5ED1-B522-XXXXXXXXX
  Provisioning UDID:	00006001-000XXXXXXXXXXXXX
  Activation Lock Status:	Disabled


OS Information: 

  System Version:	macOS 12.6 (21G115)
  Kernel Version:	Darwin 21.6.0
  Boot Volume:	Macintosh HD
  Boot Mode:	Normal
  Computer Name:	AMAQV6VGJW0JC
  User Name:	xxxxxxx (xxxxxx)
  Secure Virtual Memory:	Enabled
  System Integrity Protection:	Enabled
  Time since boot:	1 day 2:01

User Name information and HW serial information has being purposedly masked.
Comment 1 Jose Armando Porto 2022-10-15 17:09:31 UTC
Just some additional informations regarding JAVA installation: 

/ % which java
/Users/<username>/.sdkman/candidates/java/current/bin/java

/ % java --version
openjdk 19 2022-09-20
OpenJDK Runtime Environment (build 19+36-2238)
OpenJDK 64-Bit Server VM (build 19+36-2238, mixed mode, sharing)

/users/<username>/.sdkman/candidates/java % ls -lisa
total 16
1520978  0 drwxr-xr-x   6 <username>   staff   192 Oct 15 13:19 .
1499478  0 drwxr-xr-x   4 <username>   staff   128 Oct 15 12:53 ..
2027470 16 -rw-r--r--@  1 <username>   staff  6148 Oct 15 13:51 .DS_Store
1520983  0 drwxr-xr-x  10 <username>   staff   320 Oct 15 12:56 19-open
2009497  0 drwxr-xr-x  13 <username>   staff   416 Oct 15 12:56 19-oracle
2092876  0 lrwxr-xr-x   1 <username>   staff     7 Oct 15 13:19 current -> 19-open
Comment 2 Julien Nabet 2022-10-17 08:06:31 UTC
Stephan: thought you might be interested in this one since it concerns Java + macOS.
Comment 3 Stephan Bergmann 2022-10-17 08:42:35 UTC
On macOS, you need to install a JDK (not just a JRE), and the path P you add on the LibreOffice Advanced Options tab must be such that P/lib/server/libjvm.dylib exists and is of the correct CPU architecture (i.e., in your case `file .../lib/server/libjvm.dylib` should report something like "Mach-O 64-bit dynamically linked shared library arm64").
Comment 4 Julien Nabet 2022-10-17 08:56:34 UTC
(In reply to Stephan Bergmann from comment #3)
> On macOS, you need to install a JDK (not just a JRE), and the path P you add
> on the LibreOffice Advanced Options tab must be such that
> P/lib/server/libjvm.dylib exists and is of the correct CPU architecture
> (i.e., in your case `file .../lib/server/libjvm.dylib` should report
> something like "Mach-O 64-bit dynamically linked shared library arm64").

Just for curiosity:
1) do we need a JDK just for macOS or for all envs?
2) if I remember well the main difference between JRE and JDK is JRE you can use class file ("pseudo-compiled" .java file) and JDK allows do "pseudo-compile" java files in class. So why do we need JDK? Isn't the goal just to use Java class files ?
3) if it's specific to macOS, since we got specific 
STR_ERROR_JVMCREATIONFAILED_MAC in include/svtools/strings.hrc, perhaps we may change this:
    268 #define STR_ERROR_JVMCREATIONFAILED_MAC         NC_("STR_ERROR_JVMCREATIONFAILED_MAC", "%PRODUCTNAME 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 %PRODUCTNAME - Preferences - %PRODUCTNAME - Advanced.")

into:
    268 #define STR_ERROR_JVMCREATIONFAILED_MAC         NC_("STR_ERROR_JVMCREATIONFAILED_MAC", "%PRODUCTNAME requires a Java Development Kit (JDK) to perform this task. The selected JDK is defective. Please select another version or install a new JDK and select it under %PRODUCTNAME - Preferences - %PRODUCTNAME - Advanced.")

?
Comment 5 Stephan Bergmann 2022-10-17 09:14:37 UTC
(In reply to Julien Nabet from comment #4)
> Just for curiosity:
> 1) do we need a JDK just for macOS or for all envs?
[...]

(see <https://git.libreoffice.org/core/+/32bc8ddbf335dd26019edcf12758643b4cff9913%5E%21> "tdf#94716 allow Oracle's JDK to be used on OS X 10.10 and 10.11" and <https://wiki.documentfoundation.org/ReleaseNotes/5.1#macOS> etc., but I don't think it's a good idea to hijack this Bugzilla issue to discuss that tangential JDK vs. JRE topic)
Comment 6 Julien Nabet 2022-10-17 09:25:00 UTC
(In reply to Stephan Bergmann from comment #5)
> (In reply to Julien Nabet from comment #4)
> > Just for curiosity:
> > 1) do we need a JDK just for macOS or for all envs?
> [...]
> 
> (see
> <https://git.libreoffice.org/core/+/
> 32bc8ddbf335dd26019edcf12758643b4cff9913%5E%21> "tdf#94716 allow Oracle's
> JDK to be used on OS X 10.10 and 10.11" and
> <https://wiki.documentfoundation.org/ReleaseNotes/5.1#macOS> etc., but I
> don't think it's a good idea to hijack this Bugzilla issue to discuss that
> tangential JDK vs. JRE topic)

Ok just submitted a patch related to this point here:
https://gerrit.libreoffice.org/c/core/+/141447

For the main point, let's wait for Jose's feedback.
Comment 7 Jose Armando Porto 2022-10-17 12:48:06 UTC
(In reply to Stephan Bergmann from comment #3)
> On macOS, you need to install a JDK (not just a JRE), and the path P you add
> on the LibreOffice Advanced Options tab must be such that
> P/lib/server/libjvm.dylib exists and is of the correct CPU architecture
> (i.e., in your case `file .../lib/server/libjvm.dylib` should report
> something like "Mach-O 64-bit dynamically linked shared library arm64").

Hi guys...

Thanks for the answers so far. 

Let me try to get all the answers you asked:

- "On macOS, you need to install a JDK" - As far as I understand, SDKMan install different versions of JDK's from different suppliers. The idea of using SDKMan is to manage all de JDK's in my machine since I need to use different Java versions for testing purposes in other initiatives.

- "must be such that P/lib/server/libjvm.dylib exists" - Yes it does!

- "and is of the correct CPU architecture" - I executed a "file libjvm.dylib" and had the following answer: "libjvm.dylib: Mach-O 64-bit dynamically linked shared library arm64" as expected for both JDK's I have (Open and Oracle).

Hope this helps.
Comment 8 Jose Armando Porto 2022-10-17 12:52:09 UTC
(In reply to Jose Armando Porto from comment #7)
> (In reply to Stephan Bergmann from comment #3)
> > On macOS, you need to install a JDK (not just a JRE), and the path P you add
> > on the LibreOffice Advanced Options tab must be such that
> > P/lib/server/libjvm.dylib exists and is of the correct CPU architecture
> > (i.e., in your case `file .../lib/server/libjvm.dylib` should report
> > something like "Mach-O 64-bit dynamically linked shared library arm64").
> 
> Hi guys...
> 
> Thanks for the answers so far. 
> 
> Let me try to get all the answers you asked:
> 
> - "On macOS, you need to install a JDK" - As far as I understand, SDKMan
> install different versions of JDK's from different suppliers. The idea of
> using SDKMan is to manage all de JDK's in my machine since I need to use
> different Java versions for testing purposes in other initiatives.
> 
> - "must be such that P/lib/server/libjvm.dylib exists" - Yes it does!
> 
> - "and is of the correct CPU architecture" - I executed a "file
> libjvm.dylib" and had the following answer: "libjvm.dylib: Mach-O 64-bit
> dynamically linked shared library arm64" as expected for both JDK's I have
> (Open and Oracle).
> 
> Hope this helps.

Just as additional information, when I issue a "sdk list java" to check all the versions are available to install I got this for Arm64 architecture: 

"
================================================================================
Available Java Versions for macOS ARM 64bit
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 Corretto      |     | 19           | amzn    |            | 19-amzn             
               |     | 17.0.4       | amzn    |            | 17.0.4-amzn         
               |     | 11.0.16      | amzn    |            | 11.0.16-amzn        
               |     | 8.0.342      | amzn    |            | 8.0.342-amzn        
 Gluon         |     | 22.1.0.1.r17 | gln     |            | 22.1.0.1.r17-gln    
               |     | 22.1.0.1.r11 | gln     |            | 22.1.0.1.r11-gln    
 GraalVM       |     | 22.2.r17     | grl     |            | 22.2.r17-grl        
               |     | 22.2.r11     | grl     |            | 22.2.r11-grl        
               |     | 22.1.0.r17   | grl     |            | 22.1.0.r17-grl      
               |     | 22.1.0.r11   | grl     |            | 22.1.0.r11-grl      
 Java.net      |     | 20.ea.19     | open    |            | 20.ea.19-open       
               | >>> | 19           | open    | installed  | 19-open             
 Liberica      |     | 19.fx        | librca  |            | 19.fx-librca        
               |     | 19           | librca  |            | 19-librca           
               |     | 17.0.4.1.fx  | librca  |            | 17.0.4.1.fx-librca  
               |     | 17.0.4.1     | librca  |            | 17.0.4.1-librca     
               |     | 11.0.16.1.fx | librca  |            | 11.0.16.1.fx-librca 
               |     | 11.0.16.1    | librca  |            | 11.0.16.1-librca    
               |     | 8.0.345.fx   | librca  |            | 8.0.345.fx-librca   
               |     | 8.0.345      | librca  |            | 8.0.345-librca      
 Liberica NIK  |     | 22.2.r17     | nik     |            | 22.2.r17-nik        
               |     | 22.2.r11     | nik     |            | 22.2.r11-nik        
 Microsoft     |     | 17.0.4.1     | ms      |            | 17.0.4.1-ms         
               |     | 11.0.16.1    | ms      |            | 11.0.16.1-ms        
 Oracle        |     | 19           | oracle  | installed  | 19-oracle           
               |     | 17.0.4       | oracle  |            | 17.0.4-oracle       
 SapMachine    |     | 19           | sapmchn |            | 19-sapmchn          
               |     | 17.0.4.1     | sapmchn |            | 17.0.4.1-sapmchn    
               |     | 11.0.16.1    | sapmchn |            | 11.0.16.1-sapmchn   
 Semeru        |     | 18.0.2       | sem     |            | 18.0.2-sem          
               |     | 17.0.4.1     | sem     |            | 17.0.4.1-sem        
               |     | 11.0.16.1    | sem     |            | 11.0.16.1-sem       
 Temurin       |     | 19           | tem     |            | 19-tem              
               |     | 17.0.4.1     | tem     |            | 17.0.4.1-tem        
               |     | 11.0.16.1    | tem     |            | 11.0.16.1-tem       
 Zulu          |     | 19           | zulu    |            | 19-zulu             
               |     | 19.fx        | zulu    |            | 19.fx-zulu          
               |     | 17.0.4.1     | zulu    |            | 17.0.4.1-zulu       
               |     | 17.0.4.1.fx  | zulu    |            | 17.0.4.1.fx-zulu    
               |     | 11.0.16.1    | zulu    |            | 11.0.16.1-zulu      
               |     | 11.0.16.1.fx | zulu    |            | 11.0.16.1.fx-zulu   
               |     | 8.0.345      | zulu    |            | 8.0.345-zulu        
               |     | 8.0.345.fx   | zulu    |            | 8.0.345.fx-zulu     
================================================================================
Omit Identifier to install default version 17.0.4.1-tem:
    $ sdk install java
Use TAB completion to discover available versions
    $ sdk install java [TAB]
Or install a specific version by Identifier:
    $ sdk install java 17.0.4.1-tem
Hit Q to exit this list view
================================================================================
"

If you want me to test with someone else, just pick one and let me know. 

BR's
Comment 9 Stephan Bergmann 2022-10-17 13:16:18 UTC
So the "SDKMan" you mention presumably is <https://sdkman.io/>?  (I'm not too eager to try that out on my own machine, though, to debug why LO wouldn't detect the SDKs provided by it...)
Comment 10 Jose Armando Porto 2022-10-17 14:29:52 UTC
(In reply to Stephan Bergmann from comment #9)
> So the "SDKMan" you mention presumably is <https://sdkman.io/>?  (I'm not
> too eager to try that out on my own machine, though, to debug why LO
> wouldn't detect the SDKs provided by it...)

Yes... It saved my life! rs
Comment 11 Stephan Bergmann 2022-10-18 13:41:24 UTC
So I set up a non-intrusive installation of SDKMAN! with

> $ mkdir ~/sdkman
> $ cd ~/sdkman
> $ curl -o install 'https://get.sdkman.io?rcupdate=false'
> $ chmod +x install
> $ export SDKMAN_DIR="$HOME"/sdkman/inst
> $ ./install
> $ . inst/bin/sdkman-init.sh
> $ . inst/src/sdkman-main.sh
> $ sdk install java 19-open

and then adding its ~/sdkman/inst/candidates/java/19-open on the LibreOffice Advanced Options tab indeed fails with "The folder you selected does not contain a Java runtime environment.  Please select a different folder."
Comment 12 Commit Notification 2022-10-18 17:15:47 UTC
Stephan Bergmann committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/c74133420f6f9b4bc6b414b9c91d54cf8eb3f5af

tdf#151545: Restrict JvmfwkUtil_isLoadableJVM to macOS x86-64

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Jose Armando Porto 2022-10-18 17:23:39 UTC
(In reply to Commit Notification from comment #12)
> Stephan Bergmann committed a patch related to this issue.
> It has been pushed to "master":
> 
> https://git.libreoffice.org/core/commit/
> c74133420f6f9b4bc6b414b9c91d54cf8eb3f5af
> 
> tdf#151545: Restrict JvmfwkUtil_isLoadableJVM to macOS x86-64
> 
> It will be available in 7.5.0.
> 
> The patch should be included in the daily builds available at
> https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
> information about daily builds can be found at:
> https://wiki.documentfoundation.org/Testing_Daily_Builds
> 
> Affected users are encouraged to test the fix and report feedback.

Thank you for the support. 

I'll wait for the daily build to test again. 

BR's
Comment 14 Commit Notification 2022-10-25 13:59:22 UTC
Stephan Bergmann committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/0a1c83f330205439a42a8c02880ee44e0b9ae3d4

tdf#151545: Restrict JvmfwkUtil_isLoadableJVM to macOS x86-64

It will be available in 7.4.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 15 Stephan Bergmann 2022-12-05 14:47:29 UTC
*** Bug 126162 has been marked as a duplicate of this bug. ***