Learn more about how Javonet works and its benefits, and check out our customers and their success stories.
Resources for Java developers who want to use .NET libraries in their projects.
Resources for .NET developers who want to use Java JARs in their projects.
- TRY FREE
1. Getting started
- 1.1. Installing javOnet
- 1.2. Activating javOnet
- 1.3. Adding References to .NET Libraries
- 1.4. XML Configuration File
- 1.5. Using the javOnet Fluent Interface
- 1.7. Introduction to Using .NET Back-end and UI Components in Java
2. Calling methods
- 2.1. Invoking Static Methods
- 2.2. Creating Instance and Calling Instance Methods
- 2.3. Calling Generic Methods
3. Working with .NET Objects
- 3.1. Creating Instance Of Generic Object
- 3.2. Extending the .NET Class in Java and Wrapping .NET Methods
4. Fields and Properties
- 4.1. Get/Set Values for Static Fields and Properties
- 4.2. Get/Set Values for Instance Fields and Properties
5. Methods Arguments
- 5.1. Passing Reference-Type Arguments
- 5.2. Passing Arguments by Reference with “ref” and “out” Keywords
- 5.3. Passing typeof(Type) as Method Argument
- 5.4. Calling Overloaded Method Passing Null Argument
6. Nested Types
8. Arrays and Collections
- 8.1. Arrays: Using Value-Type and Reference-Type Arrays
- 8.2. Working with .NET arrays and collections from Java with Javonet
9. Embeding UI controls
10. Referencing libraries
11. Off-line activation
12. Events and Delegates
13. Disposing and Garabage Collection
14. .NET Configuration Files (AppConfig, WebConfig)
15. Exceptions, Debugging and Testing
- 15.1. Handling .NET Exceptions
- 15.2. How to debug .NET code called from Java
- 15.3. Debugging Javonet Enabled Application
16. Strongly-Typed Wrappers
Passing Reference-Type Arguments
With javOnet, you can very easily pass any .NET object as argument to any .NET method, or substitute a .NET field or property. Instances of .NET objects can be stored in your Java application using the special NObject type variable. When passing the NObject object to the .NET method, Javonet just pass it as a reference.
NObject size = Javonet.New("System.Drawing.Size"); size.set("Width", 500); size.set("Height", 100); NObject label = Javonet.New("System.Windows.Forms.Label") label.set("Size", size);
As you see you can create an instance of the Size object, set its “Width” and “Height” properties, and pass it into the Size property on the Label object. This way you can pass the object as an argument to any method or field and property.
NObject nowDateObj= Javonet.getType("DateTime").get("Now"); NObject date = Javonet.New("DateTime",1980,1,1); NObject datesDiff = nowDateObj.invoke("Subtract",date);
Here the “Now” field gets a value from DateTime. Then we create a new DateTime value, passing a date of 1980-01-01 as constructor arguments, then we subtract these dates. The datesDiff variable will store an instance of the TimeSpan object that holds the difference between now and 1980-01-01.