Out Process

A java library to run pieces of code in another JVM.

License

License

GroupId

GroupId

com.github.dyorgio.runtime
ArtifactId

ArtifactId

out-process
Last Version

Last Version

1.2.7
Release Date

Release Date

Type

Type

jar
Description

Description

Out Process
A java library to run pieces of code in another JVM.
Project URL

Project URL

https://github.com/dyorgio/out-process
Source Code Management

Source Code Management

https://github.com/dyorgio/out-process.git

Download out-process

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.dyorgio.runtime/out-process/ -->
<dependency>
    <groupId>com.github.dyorgio.runtime</groupId>
    <artifactId>out-process</artifactId>
    <version>1.2.7</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.dyorgio.runtime/out-process/
implementation 'com.github.dyorgio.runtime:out-process:1.2.7'
// https://jarcasting.com/artifacts/com.github.dyorgio.runtime/out-process/
implementation ("com.github.dyorgio.runtime:out-process:1.2.7")
'com.github.dyorgio.runtime:out-process:jar:1.2.7'
<dependency org="com.github.dyorgio.runtime" name="out-process" rev="1.2.7">
  <artifact name="out-process" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.dyorgio.runtime', module='out-process', version='1.2.7')
)
libraryDependencies += "com.github.dyorgio.runtime" % "out-process" % "1.2.7"
[com.github.dyorgio.runtime/out-process "1.2.7"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.13

Project Modules

There are no modules declared in this project.

Out Process

Build Status Maven Central

A java library to run pieces of code in another (new) JVM.

Why use it?

  • Limit code execution memory (-Xmx??).
  • Safe native code execution (Main JVM not killed by DLL/SO/DYLIB invalid address error).
  • Prevent external code to manipulate your objects.
  • Run limited one-per-jvm code (singleton) in parallel.
  • In use with external binaries can limit cpu usage too.

Usage

For single sync execution:

// Specify JVM options (optional)
OneRunOutProcess oneRun = new OneRunOutProcess("-Xmx32m");
// Run in JVM 1 and exit
int returnCode = oneRun.run(() -> System.out.println("Hello 1"));
// Call in JVM 2 and exit
System.out.println(oneRun.call(() -> System.getProperty("java.version")).getResult());

For consecutive/async executions:

// Specify JVM options (optional)
OutProcessExecutorService sharedProcess = new OutProcessExecutorService("-Xmx32m");
// Submit a task to run in external JVM
sharedProcess.submit(new CallableSerializable<String>() {
    @Override
    public String call() {
        return System.setProperty("SHARED_DATA", "EXECUTED");
    }
});
// Get shared data in external JVM and wait (.get())
String value = sharedProcess.submit(new CallableSerializable<String>() {
    @Override
    public String call() {
        return System.getProperty("SHARED_DATA");
    }
}).get();
System.out.println(value);

Maven

<dependency>
    <groupId>com.github.dyorgio.runtime</groupId>
    <artifactId>out-process</artifactId>
    <version>1.2.7</version>
</dependency>

Versions

Version
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.0
1.0.1
1.0.0