Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to instantiate a Java object within C# code base? Can anybody help?

Thanks in advance!
Posted
Comments
virusstorm 22-Jun-15 8:39am    
This is not possible. C# and Java work in two completely different fashions that do not work together in any way.
Sergey Alexandrovich Kryukov 22-Jun-15 16:30pm    
Then please look at Solution 1. :-)
—SA
virusstorm 22-Jun-15 16:41pm    
While that is a solution to the user's problem, you still aren't directly instantiating a Java object inside of C#. That library looks like it is building a proxy to sync or marshal the data to between the two run times. At the heart of it, the Java object doesn't live in the C# world. Depending on what the needs is for it, these types of solutions scare me. The potential for performance problems, buffer overflows, security risks (the list could go on) are huge red flags for me. My personal opinion is that you should build a SOAP or RESTful service to pass data between the two run times.

None the less, still a neat tool for the toolbox.
Sergey Alexandrovich Kryukov 22-Jun-15 16:47pm    
Who is talking about "direct instantiation"? I think you are right about the nature of this library, but still it denies your clear-cut "not possible". It's a matter of understanding of what exactly is possible or impossible.

From the other hand, I would agree if you or someone blamed the whole idea for being very impractical, because of this indirection, not only due performance and security risks, but dues to general unnecessary complications. I would probably try to avoid messing with such things by all means. I doubt that the Java class in question could be so valuable to mess with it. Just reimplementing it in C# would be much more neat approach.

—SA

1 solution

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Jun-15 16:30pm    
5ed. I never heard of this product.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900