Jvm.NET 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Jvm.NET --version 1.0.0
                    
NuGet\Install-Package Jvm.NET -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jvm.NET" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jvm.NET" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Jvm.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Jvm.NET --version 1.0.0
                    
#r "nuget: Jvm.NET, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Jvm.NET@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Jvm.NET&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Jvm.NET&version=1.0.0
                    
Install as a Cake Tool

Jvm.NET

A production-grade .NET library that embeds an in-process JVM and lets you drive it from C#: launch jars with arguments, rewrite bytecode at runtime, and listen to Java method / VM events.

First stable release targeting OpenJDK 21 (LTS).

Highlights

  • In-process JVM — boots libjvm.so / jvm.dll / libjvm.dylib in the current process; no java subprocess.
  • Invoke anything — load jars, find classes, call static / virtual methods, run main(String[]).
  • Bytecode rewriting — register IBytecodeTransformer callbacks backed by JVMTI ClassFileLoadHook / RetransformClasses / RedefineClasses. Ships with a C# port of ASM core for class file parsing and emission (supports unequal-length string replacement, constant pool rebuild).
  • Event listening — subscribe to MethodEntry, MethodExit, Exception, ClassLoad, ClassPrepare, ThreadStart/End, VMInit/Death. MethodEntry/MethodExit/Exception are simulated via bytecode instrumentation (方案 B) to bypass onload-only JVMTI capability restrictions of embedded JVMs.
  • Version abstraction — each JDK version lives under Abstractions/jdkXX/ and exposes a single IJvmRuntime facade, so callers don't deal with version-specific JVMTI quirks.
  • Cross-platformnet8.0 / net9.0 / net10.0 on Windows, Linux and macOS.

Install

dotnet add package Jvm.NET

Quick start

using Jvm.NET;
using Jvm.NET.Abstractions;

var runtime = JvmInitializer.Initialize(new JvmInitializationOptions
{
    JdkBinPath = @"C:\jdk-21\bin",     // or /usr/lib/jvm/jdk-21/bin
    Version    = JdkVersion.Jdk21,
    Classpath  = ["/opt/myapp/app.jar"],
});

// Run the main(String[]) of a jar in-process
runtime.Invoker.RunMain("/opt/myapp/app.jar", "com.example.App", "--verbose", "input.txt");

// Listen to every method entry (via bytecode instrumentation)
runtime.EventListener.SubscribeMethodEntry(e =>
    Console.WriteLine($"-> {e.Class.Name}.{e.MethodName}"));

// Listen to exceptions thrown inside instrumented methods
runtime.EventListener.SubscribeException(e =>
    Console.WriteLine($"ex in {e.ThrowingClass?.Name}.{e.MethodName}: {e.Exception.Class.Name}"));

// Rewrite bytecode at load time
using var token = runtime.BytecodeModifier.RegisterTransformer(new MyTransformer());
runtime.BytecodeModifier.RetransformClasses([runtime.Invoker.LoadClass("com.example.App")]);

Documentation

License

MIT © XSY_xiaoqi

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.0 273 7/17/2026
2.1.1 91 7/16/2026
2.1.0 93 7/15/2026
2.0.0 96 7/14/2026
1.0.1 91 7/14/2026
1.0.0 91 7/14/2026