MASES.JCOBridge.Templates 2.4.14

Suggested Alternatives

MASES.JNet.Templates

dotnet new install MASES.JCOBridge.Templates::2.4.14                
This package contains a .NET Template Package you can call from the shell/command line.

JCOBridge Template Usage Guide

Getting Started

Install templates

  1. Run the following command on a machine where .Net Core is installed:

dotnet new install JCOBridge.Examples.Templates

Now you have installed different templates: a simple console app, a simple app will show an AWT frame, a simple app will invokes scala classes, a simple app will invokes .NET from Java

All templates targets both .NET Core 3.1, .NET 5.0, .NET 6.0 and .NET Framework (> 4.6.1)

Use one template

  1. Run the command to install the simple console app:

dotnet new jcobridgeConsoleApp

Run the examples

  1. Run the application setting the location of the JRE-JVM library:

dotnet run --framework netcoreapp3.1 --JVMPath:"C:/Program Files/Java/jre1.8.0_241/bin/server/jvm.dll"

dotnet run --framework net6.0 --JVMPath:"C:/Program Files/Java/jre1.8.0_241/bin/server/jvm.dll"

dotnet run --framework net5.0 --JVMPath:"C:/Program Files/Java/jre1.8.0_241/bin/server/jvm.dll"

dotnet run --framework net461 --JVMPath:"C:/Program Files/Java/jre1.8.0_241/bin/server/jvm.dll"

Advanced: .NET invoking JVM languages

A lot of new programming languages (see List of JVM languages) use a JVM as runtime environment. The ready made template jcobridgeScalaApp is an example able to run Scala code from a .NET environment:

Use jcobridgeScalaApp template

  1. Run the command to install the scala app:

dotnet new jcobridgeScalaApp

Run the examples

  1. Run the application setting the location of the JRE-JVM library:

dotnet run --framework netcoreapp3.1 --JVMPath:"C:/Program Files/Java/jre1.8.0_241/bin/server/jvm.dll"

dotnet run --framework net6.0 --JVMPath:"C:/Program Files/Java/jre1.8.0_241/bin/server/jvm.dll"

dotnet run --framework net5.0 --JVMPath:"C:/Program Files/Java/jre1.8.0_241/bin/server/jvm.dll"

dotnet run --framework net461 --JVMPath:"C:/Program Files/Java/jre1.8.0_241/bin/server/jvm.dll"

Advanced: JVM invoking .NET API

Another use of JCOBridge is to invoke .NET API from JVM (or JVM enabled languages). The jcobridgeJavaNativeApp template is the starting point to write code in JVM which invokes .NET API. Any JVM enabled language (see List of JVM languages) can be used instead of Java to invoke .NET API. The template can be the starting point to use IoT boards with ready made packages for GPIO management from any JVM enabled language.

Use jcobridgeJavaNativeApp template

This template needs a JDK to be used because the Java side needs to be compiled.

  1. Run the command to install the template app:

dotnet new jcobridgeJavaNativeApp

Compile the .NET side of the project

  1. In the project root folder run the following command:

dotnet build net/jcobridgeJavaNativeApp.csproj

Compile the Java side of the project (optional)

  1. This step is optional beacuse the template comes with a compiled version of JavaNativeApp.java. Otherwise, in the project root folder run the following command:

javac src/JavaNativeApp.java -cp OutputNugetCore/netcoreapp3.1/JCOBridge.jar

Run Java code

  1. In the project root folder run the following command:

Windows: java -cp OutputNugetCore/netcoreapp3.1/JCOBridge.jar;./src JavaNativeApp

Linux: java -cp OutputNugetCore/netcoreapp3.1/JCOBridge.jar:./src JavaNativeApp

or

  1. Open your preferred Java editor in the example root and run the java code.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.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
2.4.14 1,473 8/18/2022 2.4.14 is deprecated because it is no longer maintained.
2.4.13 422 8/16/2022 2.4.13 is deprecated because it is no longer maintained.
2.4.12 444 5/7/2022
2.4.11 421 4/28/2022
2.4.10 455 4/13/2022
2.4.9 445 3/28/2022
2.4.8 418 3/19/2022
2.4.7 388 3/9/2022
2.4.6 428 2/5/2022
2.4.5 281 1/8/2022
2.4.4 246 1/3/2022
2.4.3 290 12/13/2021
2.4.1 595 11/21/2021

Template version update