>

To access any Java JAR package from .NET and call the objects defined in that package you need to reference it first. To add reference to the JAR package you call the Javonet.AddReference(…) method.

Example:
static void Main(string[] args)
{
	//Activate Javonet first
	Javonet.AddReference(@"SampleJavaJar.jar"); //adds reference to Java JAR
}

As argument you provide the relative or full path to your JAR package. If your Java package has dependencies on other packages you should add reference to each package.

Now you can access any objects stored in this package. Use static classes, create instances, call methods, use fields and properties and much more.

Check how to call Java instance method from .NET in the next article.

Download this article