Calling java from C#
-
How to call java within c#?. It would be helpful if we know the steps to use java code in C#?
-
If you are talking about directly using Java code from within a C# application, you might want to look at JNBridge. http://www.jnbridge.com/[^] I've never used it and I have no idea how much it costs, but it has a good reputation. It seems to do the job pretty well from what I can gather. If you are talking about reusing functionality but don't need direct integration then it might be easier (and cheaper) to write a wrapper that lets you talk between the two components, e.g. a web service or a call through a TCP socket or something like that. It depends what your requirements are.
The requirement is here. There are two methods available in java. Zip(string sourcefolder, string targetloction, string zipfilename); UnZip(string zipfilename, string targetfolder); We need call these methods from C#. Is there any ways to achieve whitout using JNBridge /3rd party?
-
The requirement is here. There are two methods available in java. Zip(string sourcefolder, string targetloction, string zipfilename); UnZip(string zipfilename, string targetfolder); We need call these methods from C#. Is there any ways to achieve whitout using JNBridge /3rd party?
You have a number of options: - use third-party tool like JNBridge or IKVM or similar - use a web service or other cross-process communication - write your own wrapper DLL using JNI I have no idea what your Zip/Unzip methods do, but one option (which I am sure you have considered) is to bite the bullet and rewrite them in C#. If the Java functionality isn't too complicated, this would be my preferred option if it was my project. Don't forget, you will need a JVM up and running in order to call the Java methods. They will not run natively in .NET.
-
You have a number of options: - use third-party tool like JNBridge or IKVM or similar - use a web service or other cross-process communication - write your own wrapper DLL using JNI I have no idea what your Zip/Unzip methods do, but one option (which I am sure you have considered) is to bite the bullet and rewrite them in C#. If the Java functionality isn't too complicated, this would be my preferred option if it was my project. Don't forget, you will need a JVM up and running in order to call the Java methods. They will not run natively in .NET.
-
The requirement is here. There are two methods available in java. Zip(string sourcefolder, string targetloction, string zipfilename); UnZip(string zipfilename, string targetfolder); We need call these methods from C#. Is there any ways to achieve whitout using JNBridge /3rd party?
Why don't you try some zip libraries for .NET? E.g. ICSharpCode.SharpZipLib.dll. I'd rather look for .NET alternatives than try to deal with the problems of running java code from C#. Another alternative would be to write a java "executable" which you can call with
System.Diagnostics.Process.Start()
-
Why don't you try some zip libraries for .NET? E.g. ICSharpCode.SharpZipLib.dll. I'd rather look for .NET alternatives than try to deal with the problems of running java code from C#. Another alternative would be to write a java "executable" which you can call with
System.Diagnostics.Process.Start()
-
Trying to avoid 3rd party libs. If no solution available then we may need to use 3rd party libs. Do you know any sample code that explains about writting wrapper DLL using JNI to call Java?
Why are you doing this? There is no point in writing a C# program that requires a Java library since you have to cross too many boundaries (managed -> unmanaged -> JVM) to make it work. Write your library in C# and do it the easy way.
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
Why are you doing this? There is no point in writing a C# program that requires a Java library since you have to cross too many boundaries (managed -> unmanaged -> JVM) to make it work. Write your library in C# and do it the easy way.
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
To be fair to him, he is trying to follow the advice given here[^].
Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
To be fair to him, he is trying to follow the advice given here[^].
Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
:thumbsup:
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
How to call java within c#?. It would be helpful if we know the steps to use java code in C#?
In java and only in java. 1. Wrap the java code in a java exe framework (so it can be run at the command line with 'java') 2. Add a communication layer (sockets, files or stdio) written in java. 3. Test the above. In C# and only C#. 1. Use Process to run the above 2. Write code to talk to the communication layer of the above. Benefits. A. Java code is all java. B. C# code is all C# C. No reliance on third parties. D. Unit testing can be done without relying on the other language.