Branch libreoffice-5-0-4
[LibreOffice.git] / include / jvmfwk / framework.h
blob59ffb20670a8cdc95f5a2e62073674892e082ef7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 /** @HTML */
22 #ifndef INCLUDED_JVMFWK_FRAMEWORK_H
23 #define INCLUDED_JVMFWK_FRAMEWORK_H
25 #include <jvmfwk/jvmfwkdllapi.h>
26 #include <rtl/ustring.h>
27 #include <osl/mutex.h>
28 #include "jni.h"
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 /** @file
35 <p>This library can operate in two modes, application mode and direct mode.</p>
38 <h2>Application Mode</h2>
39 In application mode the Java related settings are stored in files.
40 There are currently three files which need to be accessed. They are determined
41 by bootstrap parameters:</p>
42 <dl>
43 <dt>UNO_JAVA_JFW_VENDOR_SETTINGS</dt>
44 <dd>contains vendor and version information about JREs as well as the
45 location of plugin-libraries which are responsible for providing information
46 about these JREs as well as starting the VMs.</dd>
47 <dt>UNO_JAVA_JFW_USER_DATA</dt>
48 <dd>The file contains settings for a particular user. One can use the macro
49 $SYSUSERCONFIG in the URL which expands to a directory whery the user's data are
50 kept. On UNIX this would be the home directory and on Windows some sub-directory
51 of the &quot;Documents and Settings&quot; folder.The content of this file is an
52 implementation detail and may change in the future.</dd>
53 <dt>UNO_JAVA_JFW_SHARED_DATA</dt>
54 <dd>The file contains settings valid for all users. If a user changes a setting
55 then it takes precedence over the setting from UNO_JAVA_JFW_SHARED_DATA.
56 The content of this file is an implementation detail and may change in the future.</dd>
57 </dl>
59 <p>The values for these parameters must be file URLs and include the file name, for
60 example:<br>
61 file:///d:/MyApp/javavendors.xml<br>
62 All files are XML files and must have the extension .xml.</p>
63 <p>
64 Modifying the shared settings is currently not supported by the framework. To provide
65 Java settings for all users one can run OOo and change the settings in the
66 options dialog. These settings are made persistent in the UNO_JAVA_JFW_USER_DATA.
67 The file can then be copied into the base installation.
68 Other users will use automatically these data but can override the settings in
69 the options dialog. This mechanism may change in the future.
70 </p>
71 <p>If shared Java settings are not supported by an application then it is not
72 necessary to specify the bootstrap parameter <code>UNO_JAVA_JFW_SHARED_DATA</code>.
73 </p>
75 <p>Setting the class path used by a Java VM should not be necessary. The locations
76 of Jar files should be known by a class loader. If a jar file depends on another
77 jar file then it can be referenced in the manifest file of the first jar. However,
78 a user may add jars to the class path by using this API. If it becomes necessary
79 to add files to the class path which is to be used by all users then one can use
80 the bootstrap parameter UNO_JAVA_JFW_CLASSPATH_URLS. The value contains of file URLs
81 which must be separated by spaces.</p>
84 <h2>Direct Mode</h2>
86 <p>The direct mode is intended for a scenario where no configuration files
87 are available and a Java VM shall be run. That is,
88 the files containing the user and shared settings are not specified by the
89 bootstrap parameters UNO_JAVA_JFW_SHARED_DATA and UNO_JAVA_JFW_USER_DATA.
90 For example, tools, such as regcomp, may use this framework in a build
91 environment. Then one would want to use settings which have been specified
92 by the build environment. The framework would automatically use the
93 current settings when they change in the environment.
94 </p>
96 <p> Here are examples how regcomp could be invoked using bootstrap parameters:
97 </p>
98 <p>
99 regcomp -env:UNO_JAVA_JFW_JREHOME=file:///d:/j2re1.4.2
100 -env:&quot;UNO_JAVA_JFW_CLASSPATH=d:\\solver\\bin\\classes.jar;d:\\solver\\bin\\jurt.jar&quot;
101 -register ....
102 </p>
103 <p>If UNO_JAVA_JFW_VENDOR_SETTINGS is not set then a plugin library must be specified. For example:</p>
105 regcomp -env:UNO_JAVA_JFW_JREHOME=file:///d:/j2re1.4.2
106 -env:&quot;UNO_JAVA_JFW_CLASSPATH=d:\\solver\\bin\\classes.jar;d:\\solver\\bin\\jurt.jar&quot;
107 -register ....
108 </p>
109 <p>Additionall parameters for the Java VM can be provided. For every parameter
110 a separate bootstrap parameter must be specified. The names are
111 <code>UNO_JAVA_JFW_PARAMETER_X</code>, where X is 1,2, .. n. For example:</p>
113 regcomp -env:UNO_JAVA_JFW_PARAMETER_1=-Xdebug
114 -env:UNO_JAVA_JFW_PARAMETER_2=-Xrunjdwp:transport=dt_socket,server=y,address=8100
115 -env:UNO_JAVA_JFW_JREHOME=file:///d:/j2re1.4.2
116 -env:&quot;UNO_JAVA_JFW_CLASSPATH=d:\\solver\\bin\\classes.jar;d:\\solver\\bin\\jurt.jar&quot;
117 -register ....</p>
119 Here is a complete list of the bootstrap parameter for the direct mode:
120 </p>
121 <dl>
122 <dt>UNO_JAVA_JFW_JREHOME</dt>
123 <dd>Specifies a file URL to a JRE installation.It must ALWAYS be specified
124 in direct mode</dd>
125 <dt>UNO_JAVA_JFW_ENV_JREHOME</dt>
126 <dd>Setting this parameter, for example to &quot;1&quot; or &quot;true&quot;,
127 causes the framework to use the environment variable JAVA_HOME. It is expected
128 that JAVA_HOME contains a system path rather than a file URL. This parameter
129 and UNO_JAVA_JFW_JREHOME are mutually exclusive</dd>
130 <dt>UNO_JAVA_JFW_CLASSPATH</dt>
131 <dd>Contains the class path which is to be used by the VM. Special character,
132 such as '\','{','}','$' must be preceded with '\'. See documentation about the
133 bootstrap parameter.</dd>
134 <dt>UNO_JAVA_JFW_ENV_CLASSPATH</dt>
135 <dd>Setting this parameter,for example to &quot;1&quot; or &quot;true&quot;,
136 causes the framework to use the
137 environment variable CLASSPATH. If this variable and UNO_JAVA_JFW_CLASSPATH are
138 set then the class path is composed from UNO_JAVA_JFW_CLASSPATH and the environment
139 variable CLASSPATH.</dd>
140 <dt>UNO_JAVA_JFW_PARAMETER_X</dt>
141 <dd>Specifies a parameter for the Java VM. The X is replaced by
142 non-negative natural numbers starting with 1.</dd>
143 </dl>
145 <p>A note about bootstrap parameters. The implementation of the bootstrap
146 parameter mechanism interprets the characters '\', '$', '{', '}' as
147 escape characters. Thats why the Windows path contain double back-slashes.
148 One should also take into account that a console may have also special
149 escape characters.</p>
151 <h2>What mode is used</h2>
153 The default mode is application mode. If at least one bootstrap parameter
154 for the direct mode is provided then direct mode is used. </p>
157 All settings made by this API are done for the current user if not
158 mentioned differently.</p>
160 <h2>Other bootstrap variables</h2>
161 <dl>
162 <dt>JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY</dt>
163 <dd>This is a unofficial variable which was introduced to workaround external issues.
164 It may be removed in the future. By setting it to 1, the framework will not try to
165 find out if the system is configured to use accessibility tools or if a JRE has an
166 accessibiliy bridge installed</dd>
167 <dt>JFW_PLUGIN_FORCE_ACCESSIBILITY</dt>
168 <dd>This is a unofficial variable which was introduced to workaround external issues.
169 It may be removed in the future. By setting it to 1, the framework will override a
170 platform's desire not to probe each java backend to determine if it has an accessibility
171 bridge installed. If the JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY is set this variable has
172 no effect, and is Unix specific.</dd>
173 </dl>
176 /** indicates that a JRE has an accessibility bridge installed.
178 The flag is used with JavaInfo::nFeatures.</p>
180 #define JFW_FEATURE_ACCESSBRIDGE 0x1l
181 /** indicates that there must be an environment set up before the Java process
182 runs.
183 <p>Therefore, when a Java is selected in OO then the office must be
184 restarted, so that the changes can take effect.</p>
186 #define JFW_REQUIRE_NEEDRESTART 0x1l
188 /** error codes which are returned by functions of this API.
190 typedef enum _javaFrameworkError
192 JFW_E_NONE,
193 JFW_E_ERROR,
194 JFW_E_INVALID_ARG,
195 JFW_E_NO_SELECT,
196 JFW_E_INVALID_SETTINGS,
197 JFW_E_NEED_RESTART,
198 JFW_E_RUNNING_JVM,
199 JFW_E_JAVA_DISABLED,
200 JFW_E_NOT_RECOGNIZED,
201 JFW_E_FAILED_VERSION,
202 JFW_E_NO_JAVA_FOUND,
203 JFW_E_VM_CREATION_FAILED,
204 JFW_E_CONFIGURATION,
205 JFW_E_DIRECT_MODE
206 } javaFrameworkError;
208 /** an instance of this struct represents an installation of a Java
209 Runtime Environment (JRE).
212 Instances of this struct are created by the plug-in libraries which are used by
213 this framework (jvmfwk/vendorplugin.h). The memory of the instances is created
214 by <code>rtl_allocateMemory</code> (rtl/alloc.h). Therefore, the memory must
215 be freed by <code>rtl_freeMemory</code>. Also the contained members must be
216 freed particularly.
217 For convenience this API provides the function <code>jfw_freeJavaInfo</code>
218 which frees the objects properly. </p>
220 struct _JavaInfo
222 /** contains the vendor.
224 <p>string must be the same as the one obtained from the
225 Java system property <code>java.vendor</code>.
226 </p>
228 rtl_uString *sVendor;
229 /** contains the file URL to the installation directory.
231 rtl_uString *sLocation;
232 /** contains the version of this Java distribution.
234 <p>The version string must adhere to the rules
235 about how a version string has to be formed. These rules may
236 be vendor-dependent. Essentially the strings must syntactically
237 equal the Java system property <code>java.version</code>.
238 </p>
240 rtl_uString *sVersion;
241 /** indicates supported special features.
243 <p>For example, <code>JFW_FEATURE_ACCESSBRIDGE</code> indicates that
244 assistive technology tools are supported.</p>
246 sal_uInt64 nFeatures;
247 /** indicates requirments for running the java runtime.
249 <p>For example, it may be necessary to prepare the environment before
250 the runtime is created. That could mean, setting the
251 <code>LD_LIBRARY_PATH</code>
252 when <code>nRequirements</code> contains the flag
253 <code>JFW_REQUIRE_NEEDRESTART</code></p>
255 sal_uInt64 nRequirements;
256 /** contains data needed for the creation of the java runtime.
258 <p>There is no rule about the format and content of the sequence's
259 values. The plug-in libraries can put all data, necessary for
260 starting the java runtime into this sequence. </p>
262 sal_Sequence * arVendorData;
265 typedef struct _JavaInfo JavaInfo;
267 /** frees the memory of a <code>JavaInfo</code> object.
268 @param pInfo
269 The object which is to be freed. It can be NULL;
271 JVMFWK_DLLPUBLIC void SAL_CALL jfw_freeJavaInfo(JavaInfo *pInfo);
274 /** compares two <code>JavaInfo</code> objects for equality.
276 <p>Two <code>JavaInfo</code> objects are said to be equal if the contained
277 members of the first <code>JavaInfo</code> are equal to their counterparts
278 in the second <code>JavaInfo</code> object. The equality of the
279 <code>rtl_uString</code> members is determined
280 by the respective comparison function (see
281 <code>OUString::equals</code>).
282 Similarly the equality of the <code>sal_Sequence</code> is
283 also determined by a comparison
284 function (see <code>rtl::ByteSequence::operator ==</code>). </p>
286 Both argument pointers must be valid.</p>
287 @param pInfoA
288 the first argument.
289 @param pInfoB
290 the second argument which is compared with the first.
291 @return
292 sal_True - both object represent the same JRE.</br>
293 sal_False - the objects represend different JREs
295 JVMFWK_DLLPUBLIC sal_Bool SAL_CALL jfw_areEqualJavaInfo(
296 JavaInfo const * pInfoA,JavaInfo const * pInfoB);
298 /** determines if a Java Virtual Machine is already running.
300 <p>As long as the office and the JREs only support one
301 Virtual Machine per process the Java settings, particularly the
302 selected Java, are not effective immediately after changing when
303 a VM has already been running. That is, if a JRE A was used to start
304 a VM and then a JRE B is selected, then JRE B will only be used
305 after a restart of the office.</p>
307 By determining if a VM is running, the user can be presented a message,
308 that the changed setting may not be effective immediately.</p>
310 @param bRunning
311 [out] sal_True - a VM is running. <br/>
312 sal_False - no VM is running.
314 @return
315 JFW_E_NONE function ran successfully.<br/>
316 JFW_E_INVALID_ARG the parameter <code>bRunning</code> was NULL.
318 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_isVMRunning(sal_Bool *bRunning);
320 /** detects a suitable JRE and configures the framework to use it.
322 <p>Which JREs can be used is determined by the file javavendors.xml,
323 which contains version requirements.</p>
325 JREs can be provided by different vendors.
326 The function obtains information about JRE installations and checks if
327 there is one among them that supports
328 a set of features (currently only accessibilty is possible). If none was
329 found then it also uses a list of paths, which have been registered
330 by <code>jfw_addJRELocation</code>
331 to find JREs. Found JREs are examined in the same way.</p>
333 A JRE installation is only selected if it meets the version requirements.
334 Information about the selected JRE are made persistent so that
335 subsequent calls to <code>jfw_getSelectedJRE</code> returns this
336 information.</p>
338 While determining a proper JRE this function takes into account if a
339 user requires support for assistive technology tools. If user
340 need that support they have to set up their system accordingly.</p>
342 If the JAVA_HOME environment variable is set, this function prefers
343 the JRE which the variable refers to over other JREs.
344 If JAVA_HOME is not set or does not refer to a suitable JRE,
345 the PATH environment variable is inspected and the respective JREs
346 are checked for their suitability next.</p>
348 When support for assistive technology is required, then the
349 <code>JavaInfo</code> objects,
350 which are provided by the <code>getJavaInfo</code> functions, are
351 examined for a suitable JRE.
352 That is, the <code>JavaInfo</code> object that refers to the JRE referred to
353 by JAVA_HOME is examined. If it does not have the flag
354 <code>JFW_FEATURE_ACCESSBRIDGE</code> in the member <code>nFeatures</code>
355 then the <JavaInfo></code> objects that are related to the PATH variable
356 are examined.
357 If no suitable <code>JavaInfo</code> object is found, all <code>JavaInfo</code>
358 objects - representing Java installations on the system -, are examined.
359 As long as no <code>JavaInfo</code> object has the flag
360 <code>JFW_FEATURE_ACCESSBRIDGE</code> in the member <code>nFeatures</code>, more
361 <code>JavaInfo</code> objects are examined.
362 This goes on until a <code>JavaInfo</code> object was found which
363 represents a suitable JRE. Or no such <code>JavaInfo</code> object was found.
364 In that case the first <code>JavaInfo</code> object that was detected
365 by the algorithm described above is used to determine the JRE which is to be used.</p>
367 If there is no need for the support of assistive technology tools then
368 the first <code>JavaInfo</code> object that is detected by the algorithm
369 as described above is used.</p>
371 @param ppInfo
372 [out] a <code>JavaInfo</code> pointer, representing the selected JRE.
373 The caller has to free it by calling <code>jfw_freeJavaInfo<code>. The
374 <code>JavaInfo</code> is for informational purposes only. It is not
375 necessary to call <code>jfw_setSelectedJRE</code> afterwards.<br/>
376 <code>ppInfo</code>can be NULL. If <code>*ppInfo</code> is not null, then it is
377 overwritten, without attempting to free <code>*ppInfo</code>.
379 @return
380 JFW_E_NONE function ran successfully.<br/>
381 JFW_E_ERROR an error occurred. <br/>
382 JFW_E_NO_JAVA_FOUND no JRE was found that meets the requirements.</br>
383 JFW_E_DIRECT_MODE the function cannot be used in this mode. </br>
384 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
385 were not met.
387 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo);
389 /** provides information about all available JRE installations.
391 <p>The function determines dynamically what JREs are available. It uses
392 the plug-in libraries to provide lists of available <code>JavaInfo</code>
393 objects where each object represents a JRE (see vendorplugin.h,
394 getAllJavaInfos). It also uses a list of paths, which have been registered
395 by <code>jfw_addJRELocation</code>.
396 It is checked if the path still contains a valid JRE and if so the respective
397 <code>JavaInfo</code> object will be appended to the array unless there is
398 already an equal object.</p>
400 @param parInfo
401 [out] on returns it contains a pointer to an array of <code>JavaInfo</code>
402 pointers.
403 The caller must free the array with <code>rtl_freeMemory</code> and each
404 element of the array must be freed with <code>jfw_freeJavaInfo</code>.
405 @param pSize
406 [out] on return contains the size of array returned in <code>parInfo</code>.
408 @return
409 JFW_E_NONE function ran successfully.<br/>
410 JFW_E_INVALID_ARG at least on of the parameters was NULL<br/>
411 JFW_E_ERROR an error occurred. <br/>
412 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
413 were not met.
415 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_findAllJREs(
416 JavaInfo ***parInfo, sal_Int32 *pSize);
418 /** determines if a path points to a Java installation.
420 <p>If the path belongs to a JRE installation then it returns the
421 respective <code>JavaInfo</code> object. The function uses the
422 <code>getJavaInfoByPath</code> function of the plug-ins to obtain the
423 <code>JavaInfo</code> object. Only if the JRE found at the specified location
424 meets the version requirements as specified in the javavendors.xml file a
425 <code>JavaInfo</code> object is returned.<br/>
427 The functions only checks if a JRE exists but does not modify any settings.
428 To make the found JRE the &quot;selected JRE&quot; one has
429 to call <code>jfw_setSelectedJRE</code>.</p>
431 @param pPath
432 [in] a file URL to a directory.
433 @param pInfo
434 [out] the <code>JavaInfo</code> object which represents a JRE found at the
435 location specified by <code>pPath</code>
437 @return
438 JFW_E_NONE function ran successfully.<br/>
439 JFW_E_INVALID_ARG at least on of the parameters was NULL<br/>
440 JFW_E_ERROR an error occurred. <br/>
441 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
442 were not met.</br>
443 JFW_E_NOT_RECOGNIZED neither plug-in library could detect a JRE. <br/>
444 JFW_E_FAILED_VERSION a JRE was detected but if failed the version
445 requirements as determined by the javavendors.xml
447 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_getJavaInfoByPath(
448 rtl_uString *pPath, JavaInfo **ppInfo);
451 /** starts a Java Virtual Machine (JVM).
453 <p>The function uses the current settings to start a JVM. The actual
454 start-up code, however, is provided by the plug-in libraries. The setting
455 of the &quot;selected Java&quot; contains the information as to what vendor
456 the respective JRE comes from. In the javavendors.xml there is a mapping of
457 vendor names to the respective plug-in libraries.</p>
459 The function ultimately calls <code>startJavaVirtualMachine</code> from
460 the plug-in library.</p>
462 The <code>arOptions</code>
463 argument contains start arguments which are passed in JavaVMOption structures
464 to the VM during its creation. These
465 could be things, such as language settings, proxy settings or any other
466 properties which shall be obtainable by
467 <code>java.lang.System.getProperties</code>. One can also pass options which
468 have a certain meaning to the runtime behaviour such as -ea or -X... However,
469 one must be sure that these options can be interpreted by the VM.<br/>
470 The class path cannot be set this way. The class path is internally composed by
471 the paths to archives in a certain directory, which is preconfigured in
472 the internal data store and the respective user setting (see
473 <code>jfw_setUserClassPath</code>.</p>
475 If a JRE was selected at runtime which was different from the previous
476 setting and that JRE needs a prepared environment, for example an adapted
477 <code>LD_LIBRARY_PATH</code> environment variable, then the VM will not be
478 created and JFW_E_NEED_RESTART error is returned. If a VM is already running
479 then a JFW_E_RUNNING_JVM is returned.</p>
481 @param pInfo
482 [in] optional pointer to a specific JRE; must be caller-freed if not NULL
483 @param arOptions
484 [in] the array containing additional start arguments or NULL.
485 @param nSize
486 [in] the size of the array <code>arOptions</code>.
487 @param ppVM
488 [out] the <code>JavaVM</code> pointer.
489 @param ppEnv
490 [out] the <code>JNIenv</code> pointer.
492 @return
493 JFW_E_NONE function ran successfully.<br/>
494 JFW_E_INVALID_ARG <code>ppVM</code>, <code>ppEnv</code> are NULL or
495 <code>arOptions</code> was NULL but <code>nSize</code> was greater 0.<br/>
496 JFW_E_ERROR an error occurred. <br/>
497 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
498 were not met.</br>
499 JFW_E_JAVA_DISABLED the use of Java is currently disabled. <br/>
500 JFW_E_NO_SELECT there is no JRE selected yet. <br/>
501 JFW_E_RUNNIN_JVM there is already a VM running.<br/>
502 JFW_E_INVALID_SETTINGS the javavendors.xml has been changed and no
503 JRE has been selected afterwards. <br/>
504 JFW_E_NEED_RESTART in the current process a different JRE has been selected
505 which needs a prepared environment, which has to be done before the office
506 process. Therefore the new JRE may not be used until the office was restarted.<br/>
507 JFW_E_NEED_RESTART is also returned when Java was disabled at the beginning and
508 then the user enabled it. If then the selected JRE has the requirement
509 JFW_REQUIRE_NEEDRESTART then this error is returned. </br>
510 JFW_E_VM_CREATION_FAILED the creation of the JVM failed. The creation is performed
511 by a plug-in library and not by this API.
512 JFW_E_FAILED_VERSION the &quot;Default Mode&quot; is active. The JRE determined by
513 <code>JAVA_HOME</code>does not meet the version requirements.
515 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_startVM(
516 JavaInfo const * pInfo, JavaVMOption * arOptions, sal_Int32 nSize,
517 JavaVM ** ppVM, JNIEnv ** ppEnv);
519 /** determines the JRE that is to be used.
521 <p>When calling <code>jfw_startVM</code> then a VM is startet from
522 the JRE that is determined by this function.<br/>
523 It is not verified if the JRE represented by the <code>JavaInfo</code>
524 argument meets the requirements as specified by the javavendors.xml file.
525 However, usually one obtains the <code>JavaInfo</code> object from the
526 functions <code>jfw_findAllJREs</code> or <code>jfw_getJavaInfoByPath</code>,
527 which do verify the JREs and pass out only <code>JavaInfo</code> objects
528 which comply with the version requirements.</p>
530 If <code>pInfo</code> is NULL then the meaning is that no JRE will be
531 selected. <code>jfw_startVM</code> will then return
532 <code>JFW_E_NO_SELECT</code>.</p>
534 @param pInfo
535 [in] pointer to <code>JavaInfo</code> structure, containing data about a
536 JRE. The caller must still free <code>pInfo</code>.
538 @return
539 JFW_E_NONE function ran successfully.<br/>
540 JFW_E_ERROR An error occurred.<br/>
541 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
542 were not met.<br/>
543 JFW_E_DIRECT_MODE the function cannot be used in this mode.
545 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_setSelectedJRE(JavaInfo const *pInfo);
548 /** provides information about the JRE that is to be used.
550 <p>If no JRE is currently selected then <code>ppInfo</code> will contain
551 NULL on return.</br>
552 If the value of the element <updated> in the javavendors.xml file was
553 changed since the time when the last Java was selected then this
554 function returns <code>JFW_E_INVALID_SETTINGS</code>. This could happen during
555 a product patch. Then new version requirements may be introduced, so that
556 the currently selected JRE may not meet these requirements anymore.
557 </p>
558 <p>In direct mode the function returns information about a JRE that was
559 set by the bootstrap parameter UNO_JAVA_JFW_JREHOME.
560 </p>
561 @param ppInfo
562 [out] on return it contains a pointer to a <code>JavaInfo</code> object
563 that represents the currently selected JRE. When <code>*ppInfo</code> is not
564 NULL then the function overwrites the pointer. It is not attempted to free
565 the pointer.
567 @return
568 JFW_E_NONE function ran successfully.<br/>
569 JFW_E_INVALIDARG <code>ppInfo</code> is a NULL.<br/>
570 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
571 were not met.<br/>
572 JFW_E_INVALID_SETTINGS the javavendors.xml has been changed and no
573 JRE has been selected afterwards. <br/>
575 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_getSelectedJRE(JavaInfo **ppInfo);
578 /** determines if Java can be used.
580 <p>If <code>bEnabled</code> is <code>sal_False</code> then a call
581 to jfw_startVM will result in an error with the errorcode
582 <code>JFW_E_JAVA_DISABLED</code></p>
584 @param bEnabled
585 [in] use of Java enabled/disabled.
587 @return
588 JFW_E_NONE function ran successfully.<br/>
589 JFW_E_ERROR An error occurred.<br/>
590 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
591 were not met.<br/>
592 JFW_E_DIRECT_MODE the function cannot be used in this mode.
594 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_setEnabled(sal_Bool bEnabled);
596 /** provides the information if Java can be used.
598 <p>That is if the user enabled or disabled the use of Java.
599 </p>
601 @return
602 JFW_E_NONE function ran successfully.<br/>
603 JFW_E_INVALIDARG pbEnabled is NULL<br/>
604 JFW_E_ERROR An error occurred.<br/>
605 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
606 were not met.<br/>
607 JFW_E_DIRECT_MODE the function cannot be used in this mode.
609 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_getEnabled(sal_Bool *pbEnabled);
611 /** determines parameters which are passed to VM during its creation.
613 <p>The strings must be exactly as they are passed on the command line.
614 For example, one could pass<br/>
615 -Xdebug <br/>
616 -Xrunjdw:transport=dt_socket,server=y,address=8000<br/>
617 in order to enable debugging support.
618 </p>
620 @param arParameters
621 [in] contains the arguments. It can be NULL if nSize is 0.
622 @param nSize
623 [i] the size of <code>arArgs</code>
625 @return
626 JFW_E_NONE function ran successfully.<br/>
627 JFW_E_INVALIDARG arArgs is NULL and nSize is not 0
628 JFW_E_ERROR An error occurred.<br/>
629 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
630 were not met.<br/>
631 JFW_E_DIRECT_MODE the function cannot be used in this mode.
633 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_setVMParameters(
634 rtl_uString ** arArgs, sal_Int32 nSize);
636 /** obtains the currently used start parameters.
638 <p>The caller needs to free the returned array with
639 <code>rtl_freeMemory</code>. The contained strings must be released with
640 <code>rtl_uString_release</code>.
641 </p>
643 @param parParameters
644 [out] on returns contains a pointer to the array of the start arguments.
645 If *parParameters is not NULL then the value is overwritten.
646 @param pSize
647 [out] on return contains the size of array returned in
648 <code>parParameters</code>
650 @return
651 JFW_E_NONE function ran successfully.<br/>
652 JFW_E_INVALIDARG parParameters or pSize are NULL<br/>
653 JFW_E_ERROR An error occurred.<br/>
654 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
655 were not met.<br/>
656 JFW_E_DIRECT_MODE the function cannot be used in this mode.
658 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_getVMParameters(
659 rtl_uString *** parParameters,
660 sal_Int32 * pSize);
662 /** sets the user class path.
664 <p>When the VM is started then it is passed the class path. The
665 class path also contains the user class path set by this function.
666 The paths contained in <code>pCP</code> must be separated with a
667 system dependent path separator.</p>
669 @param pCP
670 [in] the user class path.
672 @return
673 JFW_E_NONE function ran successfully.<br/>
674 JFW_E_INVALIDARG pCP is NULL.<br/>
675 JFW_E_ERROR An error occurred.<br/>
676 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
677 were not met.<br/>
678 JFW_E_DIRECT_MODE the function cannot be used in this mode.
680 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_setUserClassPath(rtl_uString * pCP);
681 /** provides the value of the current user class path.
683 <p>The function returns an empty string if no user class path is set.
684 </p>
686 @param ppCP
687 [out] contains the user class path on return. If <code>*ppCP</code> was
688 not NULL then the value is overwritten. No attempt at freeing that string
689 is made.
691 @return
692 JFW_E_NONE function ran successfully.<br/>
693 JFW_E_INVALIDARG ppCP is NULL.<br/>
694 JFW_E_ERROR An error occurred.<br/>
695 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
696 were not met.<br/>
697 JFW_E_DIRECT_MODE the function cannot be used in this mode.
699 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_getUserClassPath(rtl_uString ** ppCP);
701 /** saves the location of a JRE.
703 <p>When <code>jfw_findAllJREs</code> is called then the paths added by this
704 function are evaluated. If the location still represents a
705 JRE then a <code>JavaInfo</code> object is created which is returned along
706 with all other <code>JavaInfo</code> objects by
707 <code>jfw_findAllJREs</code>. If the location
708 cannot be recognized then the location string is ignored. </p>
710 A validation if <code>sLocation</code> points to a JRE is not
711 performed. To do that one has to use <code>jfw_getJavaInfoByPath</code>.
712 </p>
714 Adding a path that is already stored causes no error.</p>
716 @param sLocation
717 [in] file URL to a directory which contains a JRE.
719 @return
720 JFW_E_NONE function ran successfully.<br/>
721 JFW_E_INVALIDARG sLocation is NULL.<br/>
722 JFW_E_ERROR An error occurred.<br/>
723 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
724 were not met.<br/>
725 JFW_E_DIRECT_MODE the function cannot be used in this mode.
727 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_addJRELocation(rtl_uString * sLocation);
729 /** obtains an array containing paths to JRE installations.
732 It is not guaranteed that the returned paths represent
733 a valid JRE. One can use <code>jfw_getJavaInfoByPath</code> to check this.
734 </p>
736 @param parLocations
737 [out] on return it contains the array of paths.
738 @param pSize
739 [out] on return it contains the size of the array <code>parLocations</code>.
741 @return
742 JFW_E_NONE function ran successfully.<br/>
743 JFW_E_INVALIDARG parLocation is NULL or pSize is NULL.<br/>
744 JFW_E_ERROR An error occurred.<br/>
745 JFW_E_CONFIGURATION mode was not properly set or their prerequisites
746 were not met.<br/>
747 JFW_E_DIRECT_MODE the function cannot be used in this mode.
749 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_getJRELocations(
750 rtl_uString *** parLocations, sal_Int32 * pSize);
753 /** checks if the installation of the jre still exists.
755 This function checks if the JRE described by pInfo still
756 exists. The check must be very quick because it is called by javaldx
757 (Linux, Solaris) at start up.
759 @param pInfo
760 [in] the JavaInfo object with information about the JRE.
761 @param pp_exist
762 [out] the parameter is set to either sal_True or sal_False. The value is
763 only valid if the function returns JFW_E_NONE.
765 @return
766 JFW_E_NONE the function ran successfully.</br>
767 JFW_E_ERROR an error occurred during execution.</br>
768 JFW_E_INVALID_ARG pInfo contains invalid data</br>
770 JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_existJRE(const JavaInfo *pInfo, sal_Bool *exist);
773 /** locks this API so that it cannot be used by other threads.
775 <p>If a different thread called this function before then the
776 current call is blocked until the other thread has called
777 <code>jfw_unlock()</code>. The function should be called if one
778 needs an exact snapshot of the current settings. Then the settings
779 are retrieved one by one without risk that the settings may be changed
780 by a different thread. Similiary if one needs to make settings which
781 should become effective at the same time then <code>jfw_lock</code>
782 should be called. That is, <code>jfw_startVM</code> which uses the
783 settings cannot be called before all settings have be made.</p>
785 The only functions which are not effected by <code>jfw_lock</code> are
786 <code>jfw_freeJavaInfo</code> and <code>jfw_areEqualJavaInfo</code>.
788 JVMFWK_DLLPUBLIC void SAL_CALL jfw_lock();
790 /** unlocks this API.
792 <p>This function is called after <code>jfw_lock</code>. It allows other
793 threads to use this API concurrently.</p>
795 JVMFWK_DLLPUBLIC void SAL_CALL jfw_unlock();
798 #ifdef __cplusplus
800 #endif
803 #endif
805 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */