Why doesn't my Java IDE connect to the office executable on macOS? (no office executable found!)

On my macOS Catalina I am having trouble connecting to the office executable. Currently I am trying to run the SWriter.java example from the SDK in Netbeans.

When I run the command: % make SWriter.run … from the directory of the examples in the SDK it works. It opens a document and performs some text manipulations.
But when I create a project in the Netbeans IDE with just the SWriter.java class and try to run it, I get the error that it can not find the office executable.

Recently I have read online that there are maybe some more security settings on the Apple macOS Catalina but they weren’t clear about what they would be.


Questions:

  1. Is somebody successfully programming
    LibreOffice in a graphical Java IDE
    on macOS Catalina like Netbeans, Eclipse or
    maybe Xcode?
  2. Are you aware of
    additional settings to be made
    concerning the use of a graphical
    Java IDE and security on macOS Catalina?
  3. And do you maybe know why my Java
    program is not connecting to the
    office executable?

Explanation:
In one Terminal window I start LibreOffice with the following command:

% /Applications/LibreOffice.app/Contents/MacOS/soffice --accept="socket,host=127.0.0.1,port=8100;urp;StarOffice.ServiceManager"

In another window I see the port 8100 is available:

% netstat -na | grep -i 8100 
tcp4       0      0  127.0.0.1.8100         *.*                    LISTEN

Then I run the example SWriter.java from the command line:

% make SWriter.run 
"/Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home/bin/java"  -Dcom.sun.star.lib.loader.unopath="/Applications/LibreOffice.app/Contents/MacOS" -jar /Users/<user>/LibreOffice6.4_SDK/MACOSXexample.out/class/JavaTextExamples/SWriter.jar
Connected to a running office ...
Opening an empty Writer document
Inserting a text table
Write text in the table headers
Insert something in the text table
Inserting colored Text
Insert the text frame
done

Then I wanted to start the Netbeans IDE… I used a Terminal window where I sourced the SDK environment first:

% source .bash_profile 
 ************************************************************************
 *
 * SDK environment is prepared for MacOSX
 *
 * SDK = /Users/<user>/Downloads/LibreOffice6.4_SDK
 * Office = /Applications/LibreOffice.app
 * Make = /usr/bin
 * Zip = /usr/bin
 * cat = /bin
 * sed = /usr/bin
 * C++ Compiler = /usr/bin
 * Java = /Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home
 * SDK Output directory = /Users/<user>/LibreOffice6.4_SDK
 * Auto deployment = YES
 *
 ************************************************************************

Following I started the Netbeans IDE application from the same command line:

% open -a "/Applications/NetBeans/NetBeans 11.app"

Once in this Netbeans environment I created a new project with the libraries of: /Applications/LibreOffice.app/Contents/Resources/java which for instance contains the unoil.jar and created a copy of the SWriter.java class inside the project.
When I run it I get the following error:

run:
com.sun.star.comp.helper.BootstrapException: no office executable found!
	at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:338)
	at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:302)
	at javaapplication2libreoffice.JavaApplication2libreoffice.main(JavaApplication2libreoffice.java:29)
/Users/<user>/Library/Caches/NetBeans/11.0/executor-snippets/run.xml:111: The following error occurred while executing this line:
/Users/<user>/Library/Caches/NetBeans/11.0/executor-snippets/run.xml:68: Java returned: 1
BUILD FAILED (total time: 1 second)

Please any help would be much appreciated.

Hello to everyone who is interested!,

After I did a search on google for explicitly the error message: no office executable found - I came across a page on stackoverflow.com. Someone seemed to have had the same problem and amongst the replies there was the answer for me too. So it seems that I needed to have put the program executable directory where the soffice command resides to the classpath where I also had added all the *.jar files.

In my case of programming on macOS I added the following directory to the classpath:

/Applications/LibreOffice.app/Contents/MacOS

Now the output after I run the SWriter.java example from Netbeans is without any problem and reports like the following:

run:
Connected to a running office ...
Opening an empty Writer document
Inserting a text table
Write text in the table headers
Insert something in the text table
Inserting colored Text
Insert the text frame
done
BUILD SUCCESSFUL (total time: 5 seconds)

I am so relieved!

Here you can find the original post online and the answer that comes with it: stackoverflow: no office executable found

A special thank you to Howard Rudd on stackoverflow.com!