Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5    Statistic  

Java.Initialize

Initializes JavaVM.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Java 6.5 Yes Yes Yes Yes No

MBS( "Java.Initialize"; LibPath; ClassPathList { ; Option } )

Parameters

Parameter Description Example value
LibPath Path to java library (e.g. jvm.dll)
If empty, the plugin uses the Java framework on Mac and looks into registry on Windows to find newest Java installation.

e.g. on Windows:
"C:\Program Files\Java\jre1.8.0_101\bin\server\jvm.dll"
""
ClassPathList The list of native paths to the jar files to load.
Please pass here all jar files you want to use.
"/Users/cs/Desktop/test.jar"
Option Optional
Pass a parameter for each additional option to pass to Java VM initialization.

Result

Returns OK or error.

Description

Initializes JavaVM.
You can either pass path to jvm library file or let the plugin look for it. To access classes, you need to pass paths to the jar and class files you want to use.
Returns error if already a JavaVM is initialized.
Please be aware that you can only have one VM running at a given time.

This should work fine for any Java version starting with 1.4 or newer. Tested with 1.7 and 1.8.
May not initialize probably if other plugin initialized Java before.

Returns "Using existing Java VM." in case an existing Java VM initialized by other plugin is used. In that case we can't pass your class paths or other options!

This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.

Examples

Initialize java:

Set Variable [ $r ; Value: MBS("Java.Initialize") ]
If [ MBS("Java.Initialized") ]
    Show Custom anzeigen [ "Java" ; "Java initialized." ]
Else
    Show Custom anzeigen [ "Java" ; "Java failed to initialize" & ¶ & $r ]
End If

Initialize on Linux:

Set Variable [ $r ; Value: MBS("Java.Initialize"; "/home/cs/jrel.6.0_05/lib/x64/client/libjvm.so"; "/java/test.jar¶/java/driver.jar") ]

Init with three class path entries:

MBS("Java.Initialize"; Java Test::Path to Java Library; Java Test::ClassPath1 & ¶ & Java Test::ClassPath2 & ¶ & Java Test::ClassPath3)

See also

Example Databases


Java.GetStaticField   -   Java.Initialized

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins