JavaNative.Win32Metadata 25.0.1

dotnet add package JavaNative.Win32Metadata --version 25.0.1
                    
NuGet\Install-Package JavaNative.Win32Metadata -Version 25.0.1
                    
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="JavaNative.Win32Metadata" Version="25.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JavaNative.Win32Metadata" Version="25.0.1" />
                    
Directory.Packages.props
<PackageReference Include="JavaNative.Win32Metadata" />
                    
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 JavaNative.Win32Metadata --version 25.0.1
                    
#r "nuget: JavaNative.Win32Metadata, 25.0.1"
                    
#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 JavaNative.Win32Metadata@25.0.1
                    
#: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=JavaNative.Win32Metadata&version=25.0.1
                    
Install as a Cake Addin
#tool nuget:?package=JavaNative.Win32Metadata&version=25.0.1
                    
Install as a Cake Tool

JavaNative.Win32Metadata

This project contains code to build and publish the JavaNative.Win32Metadata nuget package. The package wraps the Java Native Interface library into a winmd (Windows metadata) file. If you combine it with Microsoft.Windows.CsWin32, it will allow you to generate signatures (PInvokes) to easily use .NET Host functions in your executable/library.

Issues Stargazers NuGet

How to use it

  1. Install the required Nuget packages:

  2. Create a NativeMethods.txt file in the root folder of your project and list native functions and structures (including the one from JNI) you plan to use, for example:

    // Windows
    LoadLibrary
    
    // Java Native Interface
    JNI_TRUE
    
    JNI_CreateJavaVM
    JNI_GetDefaultJavaVMInitArgs
    

    Please also check the CSWin32 project README file for other configuration options of the PInvoke generators.

  3. You are ready to use the native functions in your code 😃

    using FreeLibrarySafeHandle __ = PInvoke.LoadLibrary($"{Environment.GetEnvironmentVariable("JAVA_HOME")}/bin/server/jvm.dll");
    JavaVMInitArgs vm_args = new()
    {
        version = JNI_VERSION.JNI_VERSION_24
    };
    _ = Java.PInvoke.JNI_GetDefaultJavaVMInitArgs(ref vm_args);
    JNI_ERROR result = Java.PInvoke.JNI_CreateJavaVM(out JavaVM* jvm, out JNIEnv* env, vm_args);
    

Contributors

Contributors

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

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
25.0.1 41 1/28/2026