Running a Java (.jar) app inside a C# app [duplicate]
Possible Duplicate:
Use a .jar java library API in C#?
I have a jar file I want to run in a C# application, is there anyway to do this?
You could use the ikvmc.exe compiler to generate a .NET assembly from this .jar
:
ikvmc.exe -target:library -out:Foo.dll Foo.jar
This will generate Foo.dll
. From now on you know what to do with the managed Foo.dll
assembly.
You can use IKVM
.
From the Uses for IKVM.NET page:
Use Java libraries in your .NET applications
IKVM.NET includes ikvmc, a Java bytecode to .NET IL translator. If you have a Java library that you would like to use in a .NET application, run ikvmc -target:library mylib.jar to create mylib.dll.
For example, the Apache FOP project is an open source XSL-FO processor written in Java that is widely used to generate PDF documents from XML source. With IKVM.NET technology, Apache FOP can be used by any .NET application.
Use this line :
System.Diagnostics.Process.Start("java -jar filename.jar");
If you want these java and c# to interact with each other use shared file or socket programming
Note you need to configure java in ur system.
精彩评论