| View previous topic :: View next topic |
| Author |
Message |
rospcc General User

Joined: 25 Apr 2005 Posts: 32
|
Posted: Mon Apr 25, 2005 12:23 am Post subject: error in importing open office SDK |
|
|
Hi,
I am trying to install and setup OpenOffice to be used with Java. I downloaded OpenOffice 1.1 SDK and installed it.
Then when I did import com.sun.star.document.*; in the beginning of my Java application program and compiled it, I got an error:
package com.sun.star.document does not exist.
I tried to run the example given in the SDK folder, I got the same error.
Does anybody know how to solve this problem?
Regards,
rospcc |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3532 Location: Hamburg, Germany
|
Posted: Mon Apr 25, 2005 1:38 am Post subject: Re: error in importing open office SDK |
|
|
| rospcc wrote: | | I am trying to install and setup OpenOffice to be used with Java. I downloaded OpenOffice 1.1 SDK and installed it. |
You don't need OOo SDK to use Java with OOo. Every OOo installation provides all the necessary JAR files. Take a look at your OOo installation directory. You will find there a folder called "program" (there is also the main program soffice located). Inside that folder is the folder "classes" located. There are all the JAR files. One of them contains "com.sun.star.document.*".
| rospcc wrote: | Then when I did import com.sun.star.document.*; in the beginning of my Java application program and compiled it, I got an error:
package com.sun.star.document does not exist.
I tried to run the example given in the SDK folder, I got the same error. |
To eliminate that error put the OOo JAR files in your CLASSPATH. That's all.
| rospcc wrote: | | Does anybody know how to solve this problem? |
Hope the above helps you. If not, ask again and provide infomations about your Java environment, OS, and OOo version.
With kind regards
hol.sten |
|
| Back to top |
|
 |
rospcc General User

Joined: 25 Apr 2005 Posts: 32
|
Posted: Mon Apr 25, 2005 2:28 am Post subject: |
|
|
Thanks for the reply hol.sten.
I've tried putting into CLASSPATH in my System environment, but it still gives me the same problem.
My system informations:
JDK = j2sdk1.4.2_04
OOo = OpenOffice.org1.1.4
OS = Win 2K Advanced server
I tried to run the following codes:
import com.sun.star.document.*;
public class test {
public static void main(String args[]){
System.out.println("hello");
}
}
Regards,
ros |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3532 Location: Hamburg, Germany
|
Posted: Mon Apr 25, 2005 10:17 am Post subject: |
|
|
| rospcc wrote: | | I've tried putting into CLASSPATH in my System environment, but it still gives me the same problem. |
Then you put it in in the wrong way
| rospcc wrote: | My system informations:
JDK = j2sdk1.4.2_04
OOo = OpenOffice.org1.1.4
OS = Win 2K Advanced server |
I used for the program provided by you this system:
JDK = j2sdk1.4.2_07 (located at c:\programme\java\j2sdk1.4.2_07)
OOo = OpenOffice.org1.1.4 (located at c:\programme\OpenOffice.org1.1.4)
OS = Windows XP Home SP2
| rospcc wrote: | I tried to run the following codes:
import com.sun.star.document.*;
public class test {
public static void main(String args[]){
System.out.println("hello");
}
} |
I tried to compile and run the code using my batch file compileAndRun.bat:
| Code: | set PATH=c:\programme\java\j2sdk1.4.2_07\bin
javac %1.java
set CLASSPATH=.
java %1 |
This was the result:
| Code: | C:\OOoTest>compileAndRun.bat test
C:\OOoTest>set PATH=c:\programme\java\j2sdk1.4.2_07\bin
C:\OOoTest>javac test.java
test.java:1: package com.sun.star.document does not exist
import com.sun.star.document.*;
^
1 error
C:\OOoTest>set CLASSPATH=.
C:\OOoTest>java test
Exception in thread "main" java.lang.NoClassDefFoundError: test
C:\OOoTest>
|
Next I changed my batch file compileAndRun.bat to:
| Code: | set PATH=c:\programme\java\j2sdk1.4.2_07\bin
set OOOLIBPATH=c:\programme\OpenOffice.org1.1.4\program\classes
set CLASSPATH=%OOOLIBPATH%\unoil.jar
javac %1.java
set CLASSPATH=.
java %1 |
This was the second result:
| Code: | C:\OOoTest>compileAndRun.bat test
C:\OOoTest>set PATH=c:\programme\java\j2sdk1.4.2_07\bin
C:\OOoTest>set OOOLIBPATH=c:\programme\OpenOffice.org1.1.4\program\classes
C:\OOoTest>set CLASSPATH=c:\programme\OpenOffice.org1.1.4\program\classes\unoil.jar
C:\OOoTest>javac test.java
C:\OOoTest>set CLASSPATH=.
C:\OOoTest>java test
hello
C:\OOoTest> |
It was my first try using javac, because I use Eclipse for developing Java applications.
With kind regards
hol.sten |
|
| Back to top |
|
 |
rospcc General User

Joined: 25 Apr 2005 Posts: 32
|
Posted: Mon Apr 25, 2005 6:47 pm Post subject: Re: error in importing open office SDK |
|
|
Hi hol.sten,
Thanks for the solution, it did work, ut only for document.*
When I tried to import other jar files, it gave me the same error, showing that the package does not exist.
Here are some of the packages that I tried to import:
import com.sun.star.bridge.XUnoUrlResolver;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.beans.XPropertySet;
I have tried added in all the jar files into the classpath.
Regards,
rospcc |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3532 Location: Hamburg, Germany
|
Posted: Mon Apr 25, 2005 10:26 pm Post subject: Re: error in importing open office SDK |
|
|
| rospcc wrote: | Thanks for the solution, it did work, ut only for document.*
When I tried to import other jar files, it gave me the same error, showing that the package does not exist. |
To put all JAR files into the CLASSPATH should suffice. I think that you misspelled something in the CLASSPATH. I will investigate your problem later. Perhaps you can post in the meantime your CLASSPATH, or even your complete compileAndRun.bat.
With kind regards
hol.sten |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3532 Location: Hamburg, Germany
|
Posted: Tue Apr 26, 2005 9:36 am Post subject: Re: error in importing open office SDK |
|
|
| rospcc wrote: | Here are some of the packages that I tried to import:
import com.sun.star.bridge.XUnoUrlResolver;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.beans.XPropertySet;
I have tried added in all the jar files into the classpath. |
OK, I adapted my code. First, the new Java source file with all your not working classes: | Code: | import com.sun.star.document.*;
import com.sun.star.bridge.XUnoUrlResolver;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.beans.XPropertySet;
public class test {
public static void main(String args[]){
System.out.println("hello");
}
} |
Second the adapted BAT file: | Code: | set PATH=c:\programme\java\j2sdk1.4.2_07\bin
set OOOLIBPATH=c:\programme\OpenOffice.org1.1.4\program\classes
set CLASSPATH=%OOOLIBPATH%\unoil.jar;%OOOLIBPATH%\ridl.jar;%OOOLIBPATH%\jurt.jar
javac %1.java
set CLASSPATH=.
java %1
|
And here the result: | Code: | C:\OOoTest>compileAndRun.bat test
C:\OOoTest>set PATH=c:\programme\java\j2sdk1.4.2_07\bin
C:\OOoTest>set OOOLIBPATH=c:\programme\OpenOffice.org1.1.4\program\classes
C:\OOoTest>set CLASSPATH=c:\programme\OpenOffice.org1.1.4\program\classes\unoil.jar;c:\programme\OpenOffice.org1.1.4\program\classes\
ridl.jar;c:\programme\OpenOffice.org1.1.4\program\classes\jurt.jar
C:\OOoTest>javac test.java
C:\OOoTest>set CLASSPATH=.
C:\OOoTest>java test
hello
C:\OOoTest>
|
What exactly is your problem?
With kind regards
hol.sten |
|
| Back to top |
|
 |
|