Page 1 of 1

[Solved] Setting up SDK for JAVA

Posted: Thu Feb 28, 2019 2:37 am
by beakhole
Followed the guide here: https://api.libreoffice.org/docs/install.html and here: http://openofficejava.blogspot.com/2009 ... g-api.html

But can't seem to get it to work, java just doesn't think the UNO API classes exist and I can't compile any scripts I write (IE I get error "package com.sun.star.uno does not exist" on compilation).

I installed the SDK and used the batch file, feeding it paths to everything it wanted. Then I checked my environment variables, but none had been added, so I manually added them all. Still get the same error, as if the SDK does not exist. Am I missing a step?

Re: Setting up SDK for JAVA

Posted: Thu Feb 28, 2019 1:46 pm
by Villeroy
I don't program Java but I think you need a 32-bit SDK because AOO for Windows is a 32-bit application.
LibreOffice is availlable as a 64-bit application for MS Windows.

Re: Setting up SDK for JAVA

Posted: Thu Feb 28, 2019 5:07 pm
by beakhole
Tried using LibreOffice 64 bit and quite a few different versions of Java, nothing works. To create a .NET app all I had to do was include the CLI dll files (from the SDK) in the project and it worked great instantly, but I wanted to try making a Java version so I could also potentially run it on Linux, but I can't even get started

Re: Setting up SDK for JAVA

Posted: Thu Feb 28, 2019 9:07 pm
by Villeroy
Can you use any Java features with your office suite?
For instance, can you download (save for editing), open this database document and then open contained tables and queries? The document contains a JDBC database.

Re: Setting up SDK for JAVA

Posted: Thu Feb 28, 2019 10:40 pm
by beakhole
So couldn't say why this works, but I went ahead and installed Eclipse along with this plugin (https://github.com/LibreOffice/loeclipse). I don't know why it works, because the plugin appears to just add the LO libraries into the project and start you off with a base script, but it does work. I had the exact same libraries added to a NetBeans project before trying it and it had the same error as in original post and wouldn't work, but with that plugin in Eclipse it does seem to work.

Re: Setting up SDK for JAVA

Posted: Thu Feb 28, 2019 11:11 pm
by Villeroy
Thank you for posting your solution. Very much apprechiated. The Document Foundation changed a lot of things to make LO more developer friendly. Less frameworks, less dependencies, less overhead, modern tools and sharing platforms. If only the changes on the user side could be as consistent as the changes on the dev side.

Re: Setting up SDK for JAVA

Posted: Thu Feb 28, 2019 11:23 pm
by beakhole
I'm sure I must have missed something silly, but I have been repeating the guides over and over and pulling my hair out without success until that Eclipse plugin somehow made it work. Glad it works, but wish I knew why!

Re: [SOLVED?]Setting up SDK for JAVA

Posted: Thu Feb 28, 2019 11:34 pm
by Villeroy
Next day it will be as obvious as the rising sun.

Re: [Solved] Setting up SDK for JAVA

Posted: Sat Sep 07, 2019 9:30 pm
by bradleyross
How are you referencing the required jar files. I am using Eclipse with Maven on MacOS and have the following POM file. Note the references to juh, unoil, ridl, and jurt. Are these the jar files that you are missing? Would it help if I put my progress so far on GitHub?

Code: Select all

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>bradleyross</groupId>
  <artifactId>libreoffice-tools</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>LibreOfficeTools</name>
  <description>Example code for manipulating LibreOffice ODF files</description>
  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
           </plugin>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-jar-plugin</artifactId>
           </plugin>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-site-plugin</artifactId>
           </plugin>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-javadoc-plugin</artifactId>
           </plugin>  
      </plugins>
  </build>  
  
  <dependencies>
  	<dependency>
  		<groupId>org.libreoffice</groupId>
  		<artifactId>juh</artifactId>
  		<version>6.2.3</version>
  	</dependency>
  	<dependency>
  		<groupId>org.libreoffice</groupId>
  		<artifactId>unoil</artifactId>
  		<version>6.2.3</version>
  	</dependency>  	
   	<dependency>
  		<groupId>org.libreoffice</groupId>
  		<artifactId>ridl</artifactId>
  		<version>6.2.3</version>
  	</dependency> 	
    <dependency>
  		<groupId>org.libreoffice</groupId>
  		<artifactId>jurt</artifactId>
  		<version>6.2.3</version>
  	</dependency>	
  </dependencies>
</project>