Difference between revisions of "Documentation/DevGuide/WritingUNO/The Java Environment in Apache OpenOffice"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Robot: Changing Category:Documentation/Developers Guide/Writing UNO Components)
m
Line 6: Line 6:
 
|NextPage=Documentation/DevGuide/WritingUNO/Troubleshooting
 
|NextPage=Documentation/DevGuide/WritingUNO/Troubleshooting
 
}}
 
}}
 +
[[zh:Zh/Documentation/DevGuide/WritingUNO/The Java Environment in OpenOffice.org]]
 
{{DISPLAYTITLE:The Java Environment in OpenOffice.org}}
 
{{DISPLAYTITLE:The Java Environment in OpenOffice.org}}
 
When UNO components written in Java are to be used within the office, the office has to be configured appropriately. Prior to {{PRODUCTNAME}} {{OOo2.x}}, this configuration happened during the installation, when the Java setup was performed. Then, a user could choose a Java Runtime Environment or choose to install a JRE. After installing the office, the selected JRE could still be changed with the ''jvmsetup'' program, which was located in the program folder. The data for running the Java Virtual Machine was stored in the ''java(.ini|rc)'' file and other configuration files.  
 
When UNO components written in Java are to be used within the office, the office has to be configured appropriately. Prior to {{PRODUCTNAME}} {{OOo2.x}}, this configuration happened during the installation, when the Java setup was performed. Then, a user could choose a Java Runtime Environment or choose to install a JRE. After installing the office, the selected JRE could still be changed with the ''jvmsetup'' program, which was located in the program folder. The data for running the Java Virtual Machine was stored in the ''java(.ini|rc)'' file and other configuration files.  

Revision as of 08:13, 29 July 2008

When UNO components written in Java are to be used within the office, the office has to be configured appropriately. Prior to OpenOffice.org 2.0, this configuration happened during the installation, when the Java setup was performed. Then, a user could choose a Java Runtime Environment or choose to install a JRE. After installing the office, the selected JRE could still be changed with the jvmsetup program, which was located in the program folder. The data for running the Java Virtual Machine was stored in the java(.ini|rc) file and other configuration files.

Template:Documentation/Note

In an office with a lower version than 2.0, the java(.ini|rc) is located in the <officepath>\user\config directory. A client can use that file to pass additional properties to the Java Virtual Machine, which are then available as system properties. For example, to pass the property MyAge, invoke Java like this:

 java -DMyAge=30 RunClass 

If you want to have that system property accessible by your Java component you can put that property into java(ini|rc) within the [Java] section. For example:

 [Java]
 Home=file:///C:/Program%20Files/Java/j2re1.4.2
 
 VMType=JRE
 Version=1.4.2
 RuntimeLib=file:///C:/Program%20Files/Java/j2re1.4.2/bin/client/jvm.dll
 SystemClasspath=d:\645m15\program\classes\classes.jar;; ...
 Java=1
 JavaScript=1
 Applets=1 
 MyAge=27

To debug a Java component, it is necessary to start the JVM with additional parameters. The parameters can be put in the java.ini the same way as they would appear on the command-line. For example, add those lines to the [Java] section:

 -Xdebug
 -Xrunjdwp:transport=dt_socket,server=y,address=8000

More about debugging can be found in the JDK documentation and in the OpenOffice.org Software Development Kit.

Java components are also affected by the following configuration settings. They can be changed in the Tools - Options dialog. In the dialog, expand the OpenOffice.org node on the left-hand side and choose Security. This brings up a new pane on the right-hand side that allows Java specific settings:

Java Setting Description
Enable If checked, Java is used with the office. This affects Java components, as well as applets.
Security checks If checked, the security manager restricts resource access of applets.
Net access Determines where an applet can connect.
ClassPath Additional jar files and directories where the JVM should search for classes. Also known as user classpath.
Applets If checked, applets are executed.

In OpenOffice.org 2.0 there is no java(.ini|rc) anymore. All basic Java settings are set in the options dialog: tree node OpenOffice.org->Java. The Parameters dialog can be used to specify the debug options and other arguments.

For applets there are still a few settings on the security panel (tree node OpenOffice.org->Security).

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages