I have a dll created in c# which does some database operation upon calling. I have to pass few parameters from a Java application to a method in the dll. Any Idea on how to do this.
OR
Any better ideas for calling a method in c# by a java application?
Thanks
Edit : My java application is a standard Dialogue Designer application from AVAYA Platform and I have developed a C# application which works on a SDK for .net only. So i need data to be passed from java application to .net application
IKVM.NET is an implementation of Java for Mono and the Microsoft .NET Framework. It includes the following components:
A Java Virtual Machine implemented in .NET
A .NET implementation of the Java class libraries
Tools that enable Java and .NET interoperability
The third point is maybe what you are looking for.
Project Site here: http://www.ikvm.net/
I looked into this a while back although I enver got far with it as the requirements changed. But I did read that using JNI, Java Native Interface may be able to help you with what you are needing to do.
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html
Hope this helps!
Related
I am new to .net programming. I heard all .net supported languages can call .net dll even written by another .net supported languages. My question is that: Can IronPython call .net dll written by c# directly or easily under its command interpretation window?
Yes, you should be able to call any managed dll.
An example of how you would do that is detailed in https://stackoverflow.com/a/14210917/413672
I heard that JNBridge will translate C# code to native Java code.( I haven't tested it).
Is there any tool available in market to translate Java code to native C# ?(or Will JNBridge also translate Java code to C# ?)
Are you talking about a source code converter, or the ability to run Java code in a CLR?
If it's the latter, you might want to look at IKVM:
IKVM.NET is an implementation of Java
for Mono and the Microsoft .NET
Framework. It includes the following
components:
A Java Virtual Machine implemented in
.NET
A .NET implementation of the Java
class libraries
Tools that enable Java
and .NET interoperability
Microsoft's Visual Studio 2005 included a Java to C# conversion tool (the Java Language Conversion Assistant). Although they announced in 2007 it wouldn't be developed further (and it isn't in VS 2008) it is still a supported product until 2015.
I don't think that direct "code translating" could be possible, what with invoking API functions? (like, each technology has it's own collections, etc.). Link that you have given, doesn't seem to be code translator, rather - libraries that allows one to connect components, like embedding java GUI inside WPF app etc.
Also, on the main page of JNBridge, they are writing:
Bridge anything Java to .NET
Bridge anything .NET to Java
So it might a good idea to check someone's site before asking about possibilities of their platform.
I have a class library written in C#, and I want to call it from a legacy native C++ application. The host application is truly native, compiled on Windows and Linux, and it’s a console application. So how can I make it call the C# class library, assuming using Microsoft .NET on Windows, and Mono on Linux?
I have looked at SWIG and wrapping with COM interfaces on Windows, but is there a standard recognized solution that works cross platform? I.e., that is generic, works with both Microsoft .NET and Mono. A write-once-use-everywhere implementation.
Solutions should expose the full class interfaces from the C# domain to the C++ domain.
Similar questions focus only on the Windows solutions, for example -
Call C# methods from C++ without using COM
If you want to do this cross platform, I would recommend going with a 100% Mono approach.
Mono has a clean Embedding API which works on Linux and Windows.
With .NET 5.0 (the successor of .NET Core) this is now possible to call C# from C++ in a cross-platform way without using Mono. Please see the solution explained in this GitHub issue using DNNE to generate a shared library and GCHandles to access C# objects.
With this you get a shared library that can be used from C or C++. Note that this will give a C-like API (no objects, like when using extern C in C++), in the future there may be tools like SWIG for C++ to overcome this limitation.
I have a couple of native applications written in C++ and C#. These are legacy applications that require data sharing between them. Currently, data sharing is through import/export of text file in some proprietary format. We are currently looking at integrating these two applications using eclipse. My questions are:
How can we integrate native applications such as c++ and c# based applications into eclipse?
What kind of data integration methods does eclipse provide for native applications?
Is eclipse the best choice for such use?
Also, it will be very helpful if you can share your experiences about integrating native applications in eclipse.
I am specifically looking at integrating native applications into eclipse just the way we would integrate a eclipse plugin written in Java. For example, what does it take to write a wrapper plugin in Java which will wrap a native tool by using JNI calls that can be integrated into eclipse just as any other eclipse plugin? Is this is a preferred approach for integrating native applications or is it a good idea to rewrite my legacy native application in Java?
I am not looking at using eclipse as a launch pad for my native applications using the "External Tools" configuration.
If you can write a JNI wrapper around your C++/C# applications, then you can use them from an Eclipse plugin.
The simplest approach is to:
repackage your C++/C# applications as DLLs (if they aren't already)
wrap them with a JNI layer
place the DLLs in the root folder of your plugin
call System.LoadLibrary() from a static initializer block in your JNI wrapper class to load required DLLs
You might find the discussion on the Eclipse newsgroup entitled Using DLL in an Eclipse plugin helpful.
There's nothing inherently specific about Eclipse here (that's not to say you can't use it as an IDE). Basically, you should look at P/Invoke, COM Interop, and MSDN's (vast) section on Managed-Unmanaged Interoperability. While you could integrate both sides with Java/SWT, and use it as the middle-man, I don't think that makes much sense.
If you just want to run the apps from inside eclipse use the external tools infrastructure.
If not, please provide more details on the integration that you seek.
I am a C# .NET programmer and am learning Python. I have downloaded IronPython, and know that it can call into .NET libraries.
I'm wondering whether there is a way to do the reverse, that is to call into some existing "classic" Python libraries in my C# code, maybe using .NET Interop.
I'd like to be able to access functions in libraries such as pygame.
Ironpython 2.0 is CPython 2.5 compatible, so pure Python that uses <=2.5 APIs should work fine under Ironpython. I believe Ironpython code can then be compiled into a DLL.
For C-extensions like Pygame, you might want to take a look at Ironclad. It's a project to allow for C-extensions to be used within Ironpython. This may also give you the native code bridge you're looking for.
You can use Python for .Net, which allows you to 'use CLR services and continue to use existing Python code and C-based extensions while maintaining native execution speeds for Python code.'
Further, 'A key goal for this project has been that Python for .NET should "work just the way you'd expect in Python", except for cases that are .NET specific (in which case the goal is to work "just the way you'd expect in C#"). In addition, with the IronPython project gaining traction, it is my goal that code written for IronPython run without modification under Python for .NET.'
Hope this helps