UNO, how to use theDesktop singleton instead of deprecated Desktop?

Alberto González Palomo alberto at
Wed Sep 21 17:45:45 UTC 2016

   I have a working Java application that uses UNO with LibreOffice 5.
   I'm using createInstanceWithContext for, 
but in the documentation it says that this interface is deprecated and 
we should use the "theDesktop singleton" instead:

   However I haven't found any information on how to do that.

   I acquire the component loader as follows:

-----------------------------------------       componentContext; serviceManager;      componentLoader;
componentContext =;
serviceManager   = componentContext.getServiceManager();
componentLoader  =
      ("", componentContext)

   I've tried writing "" instead of the 
call to serviceManager.createInstanceWithContext() but that doesn't 
compile, then I tried some other semi-random stuff but nothing worked.

   How can I do that?
   Is this documented anywhere, or is there any example that uses 
theDesktop instead of Desktop?

     Alberto González Palomo
     Toledo, España / Saarbrücken, Deutschland

More information about the LibreOffice mailing list