1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 20 /** @HTML */ 21 22 #ifndef INCLUDED_JVMFWK_FRAMEWORK_HXX 23 #define INCLUDED_JVMFWK_FRAMEWORK_HXX 24 25 #include <sal/config.h> 26 27 #include <memory> 28 #include <vector> 29 30 #include <jvmfwk/jvmfwkdllapi.hxx> 31 #include <rtl/byteseq.hxx> 32 #include <rtl/ustring.hxx> 33 #if defined __clang__ 34 #pragma clang diagnostic push 35 #pragma clang diagnostic ignored "-Wunknown-attributes" 36 #endif 37 #include <jni.h> 38 #if defined __clang__ 39 #pragma clang diagnostic pop 40 #endif 41 42 /** @file 43 <p>This library can operate in two modes, application mode and direct mode.</p> 44 45 46 <h2>Application Mode</h2> 47 In application mode the Java related settings are stored in files. 48 There are currently three files which need to be accessed. They are determined 49 by bootstrap parameters:</p> 50 <dl> 51 <dt>UNO_JAVA_JFW_VENDOR_SETTINGS</dt> 52 <dd>contains vendor and version information about JREs as well as the 53 location of plugin-libraries which are responsible for providing information 54 about these JREs as well as starting the VMs.</dd> 55 <dt>UNO_JAVA_JFW_USER_DATA</dt> 56 <dd>The file contains settings for a particular user. One can use the macro 57 $SYSUSERCONFIG in the URL which expands to a directory where the user's data are 58 kept. On UNIX this would be the home directory and on Windows some sub-directory 59 of the "Documents and Settings" folder.The content of this file is an 60 implementation detail and may change in the future.</dd> 61 <dt>UNO_JAVA_JFW_SHARED_DATA</dt> 62 <dd>The file contains settings valid for all users. If a user changes a setting 63 then it takes precedence over the setting from UNO_JAVA_JFW_SHARED_DATA. 64 The content of this file is an implementation detail and may change in the future.</dd> 65 </dl> 66 67 <p>The values for these parameters must be file URLs and include the file name, for 68 example:<br> 69 file:///d:/MyApp/javavendors.xml<br> 70 All files are XML files and must have the extension .xml.</p> 71 <p> 72 Modifying the shared settings is currently not supported by the framework. To provide 73 Java settings for all users one can run OOo and change the settings in the 74 options dialog. These settings are made persistent in the UNO_JAVA_JFW_USER_DATA. 75 The file can then be copied into the base installation. 76 Other users will use automatically these data but can override the settings in 77 the options dialog. This mechanism may change in the future. 78 </p> 79 <p>If shared Java settings are not supported by an application then it is not 80 necessary to specify the bootstrap parameter <code>UNO_JAVA_JFW_SHARED_DATA</code>. 81 </p> 82 83 <p>Setting the class path used by a Java VM should not be necessary. The locations 84 of Jar files should be known by a class loader. If a jar file depends on another 85 jar file then it can be referenced in the manifest file of the first jar. However, 86 a user may add jars to the class path by using this API. If it becomes necessary 87 to add files to the class path which is to be used by all users then one can use 88 the bootstrap parameter UNO_JAVA_JFW_CLASSPATH_URLS. The value contains of file URLs 89 which must be separated by spaces.</p> 90 91 92 <h2>Direct Mode</h2> 93 94 <p>The direct mode is intended for a scenario where no configuration files 95 are available and a Java VM shall be run. That is, 96 the files containing the user and shared settings are not specified by the 97 bootstrap parameters UNO_JAVA_JFW_SHARED_DATA and UNO_JAVA_JFW_USER_DATA. 98 For example, tools, such as regcomp, may use this framework in a build 99 environment. Then one would want to use settings which have been specified 100 by the build environment. The framework would automatically use the 101 current settings when they change in the environment. 102 </p> 103 104 <p> Here are examples how regcomp could be invoked using bootstrap parameters: 105 </p> 106 <p> 107 regcomp -env:UNO_JAVA_JFW_JREHOME=file:///d:/j2re1.4.2 108 -env:"UNO_JAVA_JFW_CLASSPATH=d:\\solver\\bin\\classes.jar;d:\\solver\\bin\\libreoffice.jar" 109 -register... 110 </p> 111 <p>If UNO_JAVA_JFW_VENDOR_SETTINGS is not set then a plugin library must be specified. For example:</p> 112 <p> 113 regcomp -env:UNO_JAVA_JFW_JREHOME=file:///d:/j2re1.4.2 114 -env:"UNO_JAVA_JFW_CLASSPATH=d:\\solver\\bin\\classes.jar;d:\\solver\\bin\\libreoffice.jar" 115 -register... 116 </p> 117 <p>Additional parameters for the Java VM can be provided. For every parameter 118 a separate bootstrap parameter must be specified. The names are 119 <code>UNO_JAVA_JFW_PARAMETER_X</code>, where X is 1,2, .. n. For example:</p> 120 <p> 121 regcomp -env:UNO_JAVA_JFW_PARAMETER_1=-Xdebug 122 -env:UNO_JAVA_JFW_PARAMETER_2=-Xrunjdwp:transport=dt_socket,server=y,address=8100 123 -env:UNO_JAVA_JFW_JREHOME=file:///d:/j2re1.4.2 124 -env:"UNO_JAVA_JFW_CLASSPATH=d:\\solver\\bin\\classes.jar;d:\\solver\\bin\\libreoffice.jar" 125 -register...</p> 126 <p> 127 Here is a complete list of the bootstrap parameter for the direct mode: 128 </p> 129 <dl> 130 <dt>UNO_JAVA_JFW_JREHOME</dt> 131 <dd>Specifies a file URL to a JRE installation.It must ALWAYS be specified 132 in direct mode</dd> 133 <dt>UNO_JAVA_JFW_ENV_JREHOME</dt> 134 <dd>Setting this parameter, for example to "1" or "true", 135 causes the framework to use the environment variable JAVA_HOME. It is expected 136 that JAVA_HOME contains a system path rather than a file URL. This parameter 137 and UNO_JAVA_JFW_JREHOME are mutually exclusive</dd> 138 <dt>UNO_JAVA_JFW_CLASSPATH</dt> 139 <dd>Contains the class path which is to be used by the VM. Special character, 140 such as '\','{','}','$' must be preceded with '\'. See documentation about the 141 bootstrap parameter.</dd> 142 <dt>UNO_JAVA_JFW_ENV_CLASSPATH</dt> 143 <dd>Setting this parameter,for example to "1" or "true", 144 causes the framework to use the 145 environment variable CLASSPATH. If this variable and UNO_JAVA_JFW_CLASSPATH are 146 set then the class path is composed from UNO_JAVA_JFW_CLASSPATH and the environment 147 variable CLASSPATH.</dd> 148 <dt>UNO_JAVA_JFW_PARAMETER_X</dt> 149 <dd>Specifies a parameter for the Java VM. The X is replaced by 150 non-negative natural numbers starting with 1.</dd> 151 </dl> 152 153 <p>A note about bootstrap parameters. The implementation of the bootstrap 154 parameter mechanism interprets the characters '\', '$', '{', '}' as 155 escape characters. That's why the Windows path contain double back-slashes. 156 One should also take into account that a console may have also special 157 escape characters.</p> 158 159 <h2>What mode is used</h2> 160 <p> 161 The default mode is application mode. If at least one bootstrap parameter 162 for the direct mode is provided then direct mode is used. </p> 163 164 <p> 165 All settings made by this API are done for the current user if not 166 mentioned differently.</p> 167 */ 168 169 /** indicates that there must be an environment set up before the Java process 170 runs. 171 <p>Therefore, when a Java is selected in OO then the office must be 172 restarted, so that the changes can take effect.</p> 173 */ 174 #define JFW_REQUIRE_NEEDRESTART 0x1l 175 176 /** error codes which are returned by functions of this API. 177 */ 178 enum javaFrameworkError 179 { 180 JFW_E_NONE, 181 JFW_E_ERROR, 182 JFW_E_NO_SELECT, 183 JFW_E_INVALID_SETTINGS, 184 JFW_E_NEED_RESTART, 185 JFW_E_RUNNING_JVM, 186 JFW_E_JAVA_DISABLED, 187 JFW_E_NOT_RECOGNIZED, 188 JFW_E_FAILED_VERSION, 189 JFW_E_NO_JAVA_FOUND, 190 JFW_E_VM_CREATION_FAILED, 191 JFW_E_CONFIGURATION, 192 JFW_E_DIRECT_MODE 193 }; 194 195 /** an instance of this struct represents an installation of a Java 196 Runtime Environment (JRE). 197 198 <p> 199 Instances of this struct are created by the plug-in libraries which are used by 200 this framework (jvmfwk/vendorplugin.h).</p> 201 */ 202 struct JavaInfo 203 { 204 /** contains the vendor. 205 206 <p>string must be the same as the one obtained from the 207 Java system property <code>java.vendor</code>. 208 </p> 209 */ 210 OUString sVendor; 211 /** contains the file URL to the installation directory. 212 */ 213 OUString sLocation; 214 /** contains the version of this Java distribution. 215 216 <p>The version string must adhere to the rules 217 about how a version string has to be formed. These rules may 218 be vendor-dependent. Essentially the strings must syntactically 219 equal the Java system property <code>java.version</code>. 220 </p> 221 */ 222 OUString sVersion; 223 /** indicates requirements for running the java runtime. 224 225 <p>For example, it may be necessary to prepare the environment before 226 the runtime is created. That could mean, setting the 227 <code>LD_LIBRARY_PATH</code> 228 when <code>nRequirements</code> contains the flag 229 <code>JFW_REQUIRE_NEEDRESTART</code></p> 230 */ 231 sal_uInt64 nRequirements; 232 /** contains data needed for the creation of the java runtime. 233 234 <p>There is no rule about the format and content of the sequence's 235 values. The plug-in libraries can put all data, necessary for 236 starting the java runtime into this sequence. </p> 237 */ 238 rtl::ByteSequence arVendorData; 239 }; 240 241 /** compares two <code>JavaInfo</code> objects for equality. 242 243 <p>Two <code>JavaInfo</code> objects are said to be equal if the contained 244 members of the first <code>JavaInfo</code> are equal to their counterparts 245 in the second <code>JavaInfo</code> object. The equality of the 246 <code>OUString</code> members is determined 247 by <code>operator ==</code>. 248 Similarly the equality of the <code>rtl::ByteSequence</code> is 249 also determined by a comparison 250 function (see <code>rtl::ByteSequence::operator ==</code>). </p> 251 <p> 252 Both argument pointers must be valid.</p> 253 @param pInfoA 254 the first argument. 255 @param pInfoB 256 the second argument which is compared with the first. 257 @return 258 true - both object represent the same JRE.</br> 259 false - the objects represent different JREs 260 */ 261 JVMFWK_DLLPUBLIC bool jfw_areEqualJavaInfo(JavaInfo const* pInfoA, JavaInfo const* pInfoB); 262 263 /** determines if a Java Virtual Machine is already running. 264 265 <p>As long as the office and the JREs only support one 266 Virtual Machine per process the Java settings, particularly the 267 selected Java, are not effective immediately after changing when 268 a VM has already been running. That is, if a JRE A was used to start 269 a VM and then a JRE B is selected, then JRE B will only be used 270 after a restart of the office.</p> 271 <p> 272 By determining if a VM is running, the user can be presented a message, 273 that the changed setting may not be effective immediately.</p> 274 275 @return 276 true iff a VM is running. 277 */ 278 JVMFWK_DLLPUBLIC bool jfw_isVMRunning(); 279 280 /** detects a suitable JRE and configures the framework to use it. 281 282 <p>Which JREs can be used is determined by the file javavendors.xml, 283 which contains version requirements.</p> 284 <p> 285 JREs can be provided by different vendors. 286 The function obtains information about JRE installations. If none was 287 found then it also uses a list of paths, which have been registered 288 by <code>jfw_addJRELocation</code> 289 to find JREs. Found JREs are examined in the same way.</p> 290 <p> 291 A JRE installation is only selected if it meets the version requirements. 292 Information about the selected JRE are made persistent so that 293 subsequent calls to <code>jfw_getSelectedJRE</code> returns this 294 information.</p> 295 <p> 296 While determining a proper JRE this function takes into account if a 297 user requires support for assistive technology tools. If user 298 need that support they have to set up their system accordingly.</p> 299 <p> 300 If the JAVA_HOME environment variable is set, this function prefers 301 the JRE which the variable refers to over other JREs. 302 If JAVA_HOME is not set or does not refer to a suitable JRE, 303 the PATH environment variable is inspected and the respective JREs 304 are checked for their suitability next.</p> 305 <p> 306 The first <code>JavaInfo</code> object that is detected by the algorithm 307 as described above is used.</p> 308 309 @param pInfo 310 [out] a <code>JavaInfo</code> pointer, representing the selected JRE. 311 The <code>JavaInfo</code> is for informational purposes only. It is not 312 necessary to call <code>jfw_setSelectedJRE</code> afterwards.<br/> 313 <code>pInfo</code>can be NULL. 314 315 @return 316 JFW_E_NONE function ran successfully.<br/> 317 JFW_E_ERROR an error occurred. <br/> 318 JFW_E_NO_JAVA_FOUND no JRE was found that meets the requirements.</br> 319 JFW_E_DIRECT_MODE the function cannot be used in this mode. </br> 320 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 321 were not met. 322 */ 323 JVMFWK_DLLPUBLIC javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo>* pInfo); 324 325 /** provides information about all available JRE installations. 326 327 <p>The function determines dynamically what JREs are available. It uses 328 the plug-in libraries to provide lists of available <code>JavaInfo</code> 329 objects where each object represents a JRE (see vendorplugin.h, 330 getAllJavaInfos). It also uses a list of paths, which have been registered 331 by <code>jfw_addJRELocation</code>. 332 It is checked if the path still contains a valid JRE and if so the respective 333 <code>JavaInfo</code> object will be appended to the array unless there is 334 already an equal object.</p> 335 336 @param parInfo 337 [out] on returns it contains a vector of <code>JavaInfo</code> pointers. 338 339 @return 340 JFW_E_NONE function ran successfully.<br/> 341 JFW_E_ERROR an error occurred. <br/> 342 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 343 were not met. 344 */ 345 JVMFWK_DLLPUBLIC javaFrameworkError 346 jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>>* parInfo); 347 348 /** determines if a path points to a Java installation. 349 350 <p>If the path belongs to a JRE installation then it returns the 351 respective <code>JavaInfo</code> object. The function uses the 352 <code>getJavaInfoByPath</code> function of the plug-ins to obtain the 353 <code>JavaInfo</code> object. Only if the JRE found at the specified location 354 meets the version requirements as specified in the javavendors.xml file a 355 <code>JavaInfo</code> object is returned.<br/> 356 <p> 357 The functions only checks if a JRE exists but does not modify any settings. 358 To make the found JRE the "selected JRE" one has 359 to call <code>jfw_setSelectedJRE</code>.</p> 360 361 @param pPath 362 [in] a file URL to a directory. 363 @param ppInfo 364 [out] the <code>JavaInfo</code> object which represents a JRE found at the 365 location specified by <code>pPath</code> 366 367 @return 368 JFW_E_NONE function ran successfully.<br/> 369 JFW_E_ERROR an error occurred. <br/> 370 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 371 were not met.</br> 372 JFW_E_NOT_RECOGNIZED neither plug-in library could detect a JRE. <br/> 373 JFW_E_FAILED_VERSION a JRE was detected but if failed the version 374 requirements as determined by the javavendors.xml 375 */ 376 JVMFWK_DLLPUBLIC javaFrameworkError jfw_getJavaInfoByPath(OUString const& pPath, 377 std::unique_ptr<JavaInfo>* ppInfo); 378 379 /** starts a Java Virtual Machine (JVM). 380 381 <p>The function uses the current settings to start a JVM. The actual 382 start-up code, however, is provided by the plug-in libraries. The setting 383 of the "selected Java" contains the information as to what vendor 384 the respective JRE comes from. In the javavendors.xml there is a mapping of 385 vendor names to the respective plug-in libraries.</p> 386 <p> 387 The function ultimately calls <code>startJavaVirtualMachine</code> from 388 the plug-in library.</p> 389 <p> 390 The <code>arOptions</code> 391 argument contains start arguments which are passed in JavaVMOption structures 392 to the VM during its creation. These 393 could be things, such as language settings, proxy settings or any other 394 properties which shall be obtainable by 395 <code>java.lang.System.getProperties</code>. One can also pass options which 396 have a certain meaning to the runtime behaviour such as -ea or -X... However, 397 one must be sure that these options can be interpreted by the VM.<br/> 398 The class path cannot be set this way. The class path is internally composed by 399 the paths to archives in a certain directory, which is preconfigured in 400 the internal data store and the respective user setting (see 401 <code>jfw_setUserClassPath</code>.</p> 402 <p> 403 If a JRE was selected at runtime which was different from the previous 404 setting and that JRE needs a prepared environment, for example an adapted 405 <code>LD_LIBRARY_PATH</code> environment variable, then the VM will not be 406 created and JFW_E_NEED_RESTART error is returned. If a VM is already running 407 then a JFW_E_RUNNING_JVM is returned.</p> 408 409 @param pInfo 410 [in] optional pointer to a specific JRE; must be caller-freed if not NULL 411 @param arOptions 412 [in] the vector containing additional start arguments. 413 @param ppVM 414 [out] the <code>JavaVM</code> pointer. 415 @param ppEnv 416 [out] the <code>JNIenv</code> pointer. 417 418 @return 419 JFW_E_NONE function ran successfully.<br/> 420 JFW_E_ERROR an error occurred. <br/> 421 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 422 were not met.</br> 423 JFW_E_JAVA_DISABLED the use of Java is currently disabled. <br/> 424 JFW_E_NO_SELECT there is no JRE selected yet. <br/> 425 JFW_E_RUNNING_JVM there is already a VM running.<br/> 426 JFW_E_INVALID_SETTINGS the javavendors.xml has been changed and no 427 JRE has been selected afterwards. <br/> 428 JFW_E_NEED_RESTART in the current process a different JRE has been selected 429 which needs a prepared environment, which has to be done before the office 430 process. Therefore the new JRE may not be used until the office was restarted.<br/> 431 JFW_E_NEED_RESTART is also returned when Java was disabled at the beginning and 432 then the user enabled it. If then the selected JRE has the requirement 433 JFW_REQUIRE_NEEDRESTART then this error is returned. </br> 434 JFW_E_VM_CREATION_FAILED the creation of the JVM failed. The creation is performed 435 by a plug-in library and not by this API. 436 JFW_E_FAILED_VERSION the "Default Mode" is active. The JRE determined by 437 <code>JAVA_HOME</code>does not meet the version requirements. 438 */ 439 JVMFWK_DLLPUBLIC javaFrameworkError jfw_startVM(JavaInfo const* pInfo, 440 std::vector<OUString> const& arOptions, 441 JavaVM** ppVM, JNIEnv** ppEnv); 442 443 /** determines the JRE that is to be used. 444 445 <p>When calling <code>jfw_startVM</code> then a VM is started from 446 the JRE that is determined by this function.<br/> 447 It is not verified if the JRE represented by the <code>JavaInfo</code> 448 argument meets the requirements as specified by the javavendors.xml file. 449 However, usually one obtains the <code>JavaInfo</code> object from the 450 functions <code>jfw_findAllJREs</code> or <code>jfw_getJavaInfoByPath</code>, 451 which do verify the JREs and pass out only <code>JavaInfo</code> objects 452 which comply with the version requirements.</p> 453 <p> 454 If <code>pInfo</code> is NULL then the meaning is that no JRE will be 455 selected. <code>jfw_startVM</code> will then return 456 <code>JFW_E_NO_SELECT</code>.</p> 457 458 @param pInfo 459 [in] pointer to <code>JavaInfo</code> structure, containing data about a 460 JRE. The caller must still free <code>pInfo</code>. 461 462 @return 463 JFW_E_NONE function ran successfully.<br/> 464 JFW_E_ERROR An error occurred.<br/> 465 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 466 were not met.<br/> 467 JFW_E_DIRECT_MODE the function cannot be used in this mode. 468 */ 469 JVMFWK_DLLPUBLIC javaFrameworkError jfw_setSelectedJRE(JavaInfo const* pInfo); 470 471 /** provides information about the JRE that is to be used. 472 473 <p>If no JRE is currently selected then <code>ppInfo</code> will contain 474 NULL on return.</br> 475 If the value of the element <updated> in the javavendors.xml file was 476 changed since the time when the last Java was selected then this 477 function returns <code>JFW_E_INVALID_SETTINGS</code>. This could happen during 478 a product patch. Then new version requirements may be introduced, so that 479 the currently selected JRE may not meet these requirements anymore. 480 </p> 481 <p>In direct mode the function returns information about a JRE that was 482 set by the bootstrap parameter UNO_JAVA_JFW_JREHOME. 483 </p> 484 @param ppInfo 485 [out] on return it contains a pointer to a <code>JavaInfo</code> object 486 that represents the currently selected JRE. When <code>*ppInfo</code> is not 487 NULL then the function sets the pointer. 488 489 @return 490 JFW_E_NONE function ran successfully.<br/> 491 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 492 were not met.<br/> 493 JFW_E_INVALID_SETTINGS the javavendors.xml has been changed and no 494 JRE has been selected afterwards. <br/> 495 */ 496 JVMFWK_DLLPUBLIC javaFrameworkError jfw_getSelectedJRE(std::unique_ptr<JavaInfo>* ppInfo); 497 498 /** determines if Java can be used. 499 500 <p>If <code>bEnabled</code> is <code>false</code> then a call 501 to jfw_startVM will result in an error with the errorcode 502 <code>JFW_E_JAVA_DISABLED</code></p> 503 504 @param bEnabled 505 [in] use of Java enabled/disabled. 506 507 @return 508 JFW_E_NONE function ran successfully.<br/> 509 JFW_E_ERROR An error occurred.<br/> 510 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 511 were not met.<br/> 512 JFW_E_DIRECT_MODE the function cannot be used in this mode. 513 */ 514 JVMFWK_DLLPUBLIC javaFrameworkError jfw_setEnabled(bool bEnabled); 515 516 /** provides the information if Java can be used. 517 518 <p>That is if the user enabled or disabled the use of Java. 519 </p> 520 521 @return 522 JFW_E_NONE function ran successfully.<br/> 523 JFW_E_ERROR An error occurred.<br/> 524 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 525 were not met.<br/> 526 JFW_E_DIRECT_MODE the function cannot be used in this mode. 527 */ 528 JVMFWK_DLLPUBLIC javaFrameworkError jfw_getEnabled(bool* pbEnabled); 529 530 /** determines parameters which are passed to VM during its creation. 531 532 <p>The strings must be exactly as they are passed on the command line. 533 For example, one could pass<br/> 534 -Xdebug <br/> 535 -Xrunjdw:transport=dt_socket,server=y,address=8000<br/> 536 in order to enable debugging support. 537 </p> 538 539 @param arParameters 540 [in] contains the arguments. 541 542 @return 543 JFW_E_NONE function ran successfully.<br/> 544 JFW_E_ERROR An error occurred.<br/> 545 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 546 were not met.<br/> 547 JFW_E_DIRECT_MODE the function cannot be used in this mode. 548 */ 549 JVMFWK_DLLPUBLIC javaFrameworkError jfw_setVMParameters(std::vector<OUString> const& arArgs); 550 551 /** obtains the currently used start parameters. 552 553 @param parParameters 554 [out] on returns contains a pointer to the array of the start arguments. 555 556 @return 557 JFW_E_NONE function ran successfully.<br/> 558 JFW_E_ERROR An error occurred.<br/> 559 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 560 were not met.<br/> 561 JFW_E_DIRECT_MODE the function cannot be used in this mode. 562 */ 563 JVMFWK_DLLPUBLIC javaFrameworkError jfw_getVMParameters(std::vector<OUString>* parParameters); 564 565 /** sets the user class path. 566 567 <p>When the VM is started then it is passed the class path. The 568 class path also contains the user class path set by this function. 569 The paths contained in <code>pCP</code> must be separated with a 570 system dependent path separator.</p> 571 572 @param pCP 573 [in] the user class path. 574 575 @return 576 JFW_E_NONE function ran successfully.<br/> 577 JFW_E_ERROR An error occurred.<br/> 578 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 579 were not met.<br/> 580 JFW_E_DIRECT_MODE the function cannot be used in this mode. 581 */ 582 JVMFWK_DLLPUBLIC javaFrameworkError jfw_setUserClassPath(OUString const& pCP); 583 /** provides the value of the current user class path. 584 585 <p>The function returns an empty string if no user class path is set. 586 </p> 587 588 @param ppCP 589 [out] contains the user class path on return. 590 591 @return 592 JFW_E_NONE function ran successfully.<br/> 593 JFW_E_ERROR An error occurred.<br/> 594 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 595 were not met.<br/> 596 JFW_E_DIRECT_MODE the function cannot be used in this mode. 597 */ 598 JVMFWK_DLLPUBLIC javaFrameworkError jfw_getUserClassPath(OUString* ppCP); 599 600 /** saves the location of a JRE. 601 602 <p>When <code>jfw_findAllJREs</code> is called then the paths added by this 603 function are evaluated. If the location still represents a 604 JRE then a <code>JavaInfo</code> object is created which is returned along 605 with all other <code>JavaInfo</code> objects by 606 <code>jfw_findAllJREs</code>. If the location 607 cannot be recognized then the location string is ignored. </p> 608 <p> 609 A validation if <code>sLocation</code> points to a JRE is not 610 performed. To do that one has to use <code>jfw_getJavaInfoByPath</code>. 611 </p> 612 <p> 613 Adding a path that is already stored causes no error.</p> 614 615 @param sLocation 616 [in] file URL to a directory which contains a JRE. 617 618 @return 619 JFW_E_NONE function ran successfully.<br/> 620 JFW_E_ERROR An error occurred.<br/> 621 JFW_E_CONFIGURATION mode was not properly set or their prerequisites 622 were not met.<br/> 623 JFW_E_DIRECT_MODE the function cannot be used in this mode. 624 */ 625 JVMFWK_DLLPUBLIC javaFrameworkError jfw_addJRELocation(OUString const& sLocation); 626 627 /** checks if the installation of the jre still exists. 628 629 This function checks if the JRE described by pInfo still 630 exists. The check must be very quick because it is called by javaldx 631 (Linux, Solaris) at start up. 632 633 @param pInfo 634 [in] the JavaInfo object with information about the JRE. 635 @param pp_exist 636 [out] the parameter is set to either true or false. The value is 637 only valid if the function returns JFW_E_NONE. 638 639 @return 640 JFW_E_NONE the function ran successfully.</br> 641 JFW_E_ERROR an error occurred during execution.</br> 642 */ 643 JVMFWK_DLLPUBLIC javaFrameworkError jfw_existJRE(const JavaInfo* pInfo, bool* exist); 644 645 /** locks this API so that it cannot be used by other threads. 646 647 <p>If a different thread called this function before then the 648 current call is blocked until the other thread has called 649 <code>jfw_unlock()</code>. The function should be called if one 650 needs an exact snapshot of the current settings. Then the settings 651 are retrieved one by one without risk that the settings may be changed 652 by a different thread. Similarity if one needs to make settings which 653 should become effective at the same time then <code>jfw_lock</code> 654 should be called. That is, <code>jfw_startVM</code> which uses the 655 settings cannot be called before all settings have be made.</p> 656 <p> 657 The only functions which is not effected by <code>jfw_lock</code> is 658 <code>jfw_areEqualJavaInfo</code>. 659 */ 660 JVMFWK_DLLPUBLIC void jfw_lock(); 661 662 /** unlocks this API. 663 664 <p>This function is called after <code>jfw_lock</code>. It allows other 665 threads to use this API concurrently.</p> 666 */ 667 JVMFWK_DLLPUBLIC void jfw_unlock(); 668 669 #endif 670 671 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 672