spawn static method

void spawn({
  1. String? dylibDir,
  2. List<String> jvmOptions = const [],
  3. List<String> classPath = const [],
  4. bool ignoreUnrecognized = false,
  5. int jniVersion = JniVersions.JNI_VERSION_1_6,
})

Spawn an instance of JVM using JNI. This method should be called at the beginning of the program with appropriate options, before other isolates are spawned.

dylibDir is path of the directory where the wrapper library is found. This parameter needs to be passed manually on Dart standalone target, since we have no reliable way to bundle it with the package.

jvmOptions, ignoreUnrecognized, & jniVersion are passed to the JVM. Strings in classPath, if any, are used to construct an additional JVM option of the form "-Djava.class.path={paths}".

Implementation

static void spawn({
  String? dylibDir,
  List<String> jvmOptions = const [],
  List<String> classPath = const [],
  bool ignoreUnrecognized = false,
  int jniVersion = JniVersions.JNI_VERSION_1_6,
}) {
  final status = spawnIfNotExists(
    dylibDir: dylibDir,
    jvmOptions: jvmOptions,
    classPath: classPath,
    ignoreUnrecognized: ignoreUnrecognized,
    jniVersion: jniVersion,
  );
  if (status == false) {
    throw JniVmExistsError();
  }
}