Intel® Software Network Knowledge Base Wiki


Constructing Nav Tree
One Moment...

(refresh menu)



 
Welcome, Guest | Quick Login | Register

.NET


How to Reference Java .class Files from a .NET Project

Version 9, Changed by KYLE LEWIS on 1/2/2008
Created by: KYLEX.S.LEWIS@INTEL.COM
Challenge
 
Use the functionality of a Java .class file in a .NET project. Because .NET is language-neutral, you can use assemblies created from Java .class files in any .NET project written in any .NET language.

The separate item,"How to Convert Java .class Files to .NET Executables" shows how to convert a working set of Java .class files into a .NET assembly using the Jblmp utility. The separate item, "How to Share and Reference .NET Assemblies" demonstrates how to share this assembly among one or more .NET executables, as well as how to reference an assembly from another assembly.
Solution
 
In the .NET project, reference the assembly created from the appropriate Java .class files. For example, suppose you rewrite the file from "How to Convert Java .class Files to .NET Executables," GuiApplicationLauncher.java, in C# as shown below:

 
GuiApplicationLauncher.cs
namespace CSharp

     public sealed class GuiApplicationLauncher
    
          public static void Main(string[] args)
          
               new integrated.GuiApplication().init()
         
     

 
Compile this code using the C# command-line compiler and reference the DotNetGui.dll assembly created from the Java .class files:
csc /target:exe /out:ThirdDotNetApplication.exe /r:DotNetGui.dll GuiApplicationLauncher.cs

 
Looking at ThirdDotNetApplication.exe with IL DASM reveals the C# origins of GuiApplicationLauncher.class. For example, notice that Main now starts with an uppercase M:



A final look at the manifest shows that the Java origin of the DotNetGui assembly is now only visible inside the DotNetGui assembly itself:



 
Source
 


Served
25 Knowledge Bases
604 Pages
Search
Powering Up Search...


Vote on this Page

Tags For This Page
Loading Tags..

Tag This



Additional legal information