There could be many reasons. What error message are you getting when you try to run from the command line?
The most common reason, in my personal experience, is not having the correct classpath configured, but it really depends.
There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
Joined: Jul 19, 2007
this is my error i set path and classpath properly
java.lang.Exception: java.io.IOException: Cannot run program "\soffice": CreateProcess error=2, The system cannot find the file specified java.io.IOException: Cannot run program "\soffice": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at com.sun.star.comp.beans.LocalOfficeConnection$OfficeService.startupService(LocalOfficeConnection.java:793) at com.sun.star.comp.beans.LocalOfficeConnection.connect(LocalOfficeConnection.java:344) at com.sun.star.comp.beans.LocalOfficeConnection.getComponentContext(LocalOfficeConnection.java:248) at com.sun.star.comp.beans.OOoBean.setOOoConnection(OOoBean.java:188) at com.sun.star.comp.beans.OOoBean.getOOoConnection(OOoBean.java:288) at com.sun.star.comp.beans.OOoBean.getMultiServiceFactory(OOoBean.java:308) at com.sun.star.comp.beans.OOoBean.loadFromURL(OOoBean.java:578) at com.officebean.OOoBeanViewer.createBlankDoc(OOoBeanViewer.java:286) at com.officebean.OOoBeanViewer.access$1(OOoBeanViewer.java:278) at com.officebean.OOoBeanViewer$1.actionPerformed(OOoBeanViewer.java:70)
when i run my program in eclipse IDE working fine and also "soffice.bin" and "soffice.exe" process created in windows task manager once process created i can run in command prompt without error message
The error message should give you a hint: Cannot run program "\soffice": CreateProcess error=2, The system cannot find the file specified
Where is the soffice.exe file located and how are you referring to it in your program? It looks like your program can't find soffice.exe if you run it from the command line. Try using the absolute path to the executable instead of a relative path (for example "C:\\Program Files\\Something\\soffice.exe" instead of "\\soffice").