Precautions for OpenOffice integration in eclipse

Source: Internet
Author: User
OpenOffice is an excellent open-source office suite contributed by Sun to open-source Community . If you inherit from eclipse, it is equivalent to adding office suite support to eclipse. For this reason, the author tries as follows.
OpenOffice provides several jar packages specifically for embedding OpenOffice in Java and calling OpenOffice services. In its own example, there are officebean and officedev for reference. However, if swt_awt is used for embedding them directly, the officebean library cannot be found. The reason is that when the localofficeconnection file in officeben. Jar loads the officebean library, the following Code :
String asharedlibname = getprogrampath () + Java. Io. file. Separator + system. maplibraryname (office_lib_name );
System. Load (asharedlibname );
Getprogrampath () Uses
File Path = nativelibraryloader. getresource (this. getclass (). getclassloader (), aexec );
Specifically, aexecis the soffice.exe file, that is, the name of the OpenOffice Startup File. Nativelibraryloader. getresource uses classloader. getresource (s) to load resources.
The problem occurs in the final classloader. getresource (s ). In normal Java Program To obtain the path of asharedlibname. However, in eclipse, no matter how path is set or classpath is passed, eclipse cannot find soffice to Load Library errors.
After finding the root cause of the problem, you can directly modify getprogrampath. In order not to install OpenOffice on the client, copy the directory after OpenOffice installation to the plug-in directory, and then use the following code to obtain the plug-in directory:
Mprogrampath = platform. getbundle ("org. OpenOffice"). getlocation () + "program"; if (mprogrampath. indexof ("@/")> 0 ){
Mprogrampath = mprogrampath. substring (mprogrampath. indexof ("@/") + 2 );
}
In this way, you can load it. However, do not forget to set the above path in the path, because officebean uses the default method when loading other components. You must set the path in the path to find it correctly. This requires the installation program to write the path to the path.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.