Monday, May 20, 2013

How To Use Java Packages In .NET

Introduction

In this tip, I am going to describe how to use Java Packages in .NET using IKVM.NET. In my previous tip, I have briefly described all about IKVM.NET. So before reading this tip, you can refer to that one. IKVM.NET provides this facility with the help of OpenJDK Project.

Using the Code

So for using IKVM.NET library, first of all you have to download it from here. After downloading IKVM.NET , unzip the file. You can see the following folders and files inside unzip file.

Inline image 1

Now suppose you are creating a project in C#.NET and you want to use Java packages in this project, then we need to add reference of the package which is required. For each package, there is a separate DLL file so you can add any package.

Inline image 2

As you can see in the above image, there are lots of packages present as DLL file so you can add references of the required packages.

Here, I am going to use GZIP Compression class present in Java.util.zip package of Java. I know all of you have a question now, why I am using GZIP compression of Java while it presents in .NET already. So the reason behind that is GZIP compression provided by Java is better than .NET.

Read more: Codeproject
QR: Inline image 3