We have made a significant advancement in the Javonet.io enhancing its stability and the functionality. The Javonet.io is a cloud based service that allows for the instant conversion of any kind of the .NET Dll (no modification is needed, neither pre or post development) to fully functional ready-to-use JAR package.
The conversion is done within minutes directly on the website. The result of the conversion is a downloadable JAR package that can be immediately added and referenced in any Java project. All the code that is present in the .NET DLL will be reflected in the JAR file one to one, so the existing .NET documentation (that contains the particular classes, properties, method names etc.) can be used for the Java development.
Below you can find the code of the sample DLL that we have prepared for you to make your first trial of Javonet.io, you can copy it or download the ready DLL with the link below.
public class Robot { public int NumberOfArms { get; set; } public RobotType Type { get; set; } public string Name; public Robot(string name) { Name = name; } public void SayMyName() { Console.WriteLine($"Hi! My name is {Name}"); } public static void WaveHello() { Console.WriteLine($"Hi! Thanks for trying out javonet warapper"); } public List<int> GenerateList(int start, int count) { return Enumerable.Range(start, count).ToList(); } } public enum RobotType { Simple, Complex }
Below you can see the example usage scenario of the ready to use JAR package that has been generated out of the provided DLL:
import Sample.Robot; import Sample.RobotType; public class Main { public static void main(String[] args) { Common.Activation.setLicense("EMAIL", "KEY"); Robot.WaveHello(); Robot robot = new Robot("Bob"); robot.setNumberOfArms(1); robot.setType(RobotType.Simple); robot.SayMyName(); System.out.println("I am " + robot.getType() + " type robot"); System.out.println("I have " + robot.getNumberOfArms() + " arms"); } }
Here in Eclipse IDE:
The generated Jar package contains auto generated source code that replicated your entire .NET API as strongly-typed Java methods. The generated classes use Javonet technology inside to route the calls to .NET objects and retrieve results.
From end-developer perspective the generated code provides seamless experience like working with pure Java. In order to provide class hierarchy from .NET we additionally wrap .NET inherited interfaces and classes used by wrapped types and map the collections to Java collections so you iterate them easily on Java side. Check the part of the generated code below to better understand how wrapper exposes your .NET code for Java developers:
public Robot(java.lang.String name) { try { javonetHandle = Javonet.New("Sample.Robot", name); } catch (JavonetException _javonetException) { _javonetException.printStackTrace(); } }
Upload our sample .NET DLL or any of your own and test Javonet.io and it’s capabilities!
How to convert the DLL to JAR package:
- Navigate to Javonet.io.
- Drop your .NET DLL file onto our drop wizard area.
- Click “Generate Java Package”.
- Wait a little …
- Save the ready-to-use JAR package on your drive!
- Refrence the package in your Java app and use it!