Calling Java Code

B

bvh

depending on the format of what you're trying to do, you can
use XMLRPC to do it.

Here is an xmlrpc class for C#. I haven't used it so I can't say
whether or not its any good.

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=971&lngWId=10

Of course this is appropriate if you are working on a web based
project, or at very least a client server project and the
procedure call doesn't involve something fancy like renering
a SWING interface, but rather is a simple object oriented method
call. For example if you have business rules in a Java object
and no time or inclination to rework them into C#.

Of course, SOAP is another option along the same lines, but
IMHO XMLRPC is less work than SOAP because the guts of the
request are typically handled for you.
 
C

Coatl

J

James Black

Jim said:
Can you call exisiting Java classes from C#?

Is it written in MSs Java (I think it is J#)? If so then you might be
able to (I have never done it that).

You can execute it as a program if nothing else.

I don't know what you mean by call a java class, that is somewhat vague.
 
B

Bruno Jouhier [MVP]

If it was written in MS Java, it was probably written with Visual J++ rather
than Visual J#. So, you would need to take your source code and recompile it
with Visual J#. This will give you .NET assemblies that you will be able to
reference from your C# project, like any .NET assembly.

Visual J# offers very good source code compatibility with Visual J++, so
this should be rather seamless. Story would be a bit different if your Java
source was based on SUN's latest JDK.

Bruno
 
J

JDeats

C# code compiles for and targets the .NET Framework CLR, Java code
targets JVM. Both are virtual machines that sit on top of the native
OS, they both follow very different binary standards for interfaces.
In order to have true interop between the two you'd need a virtual
machine that can marshall calls between the two platforms at a binary
level. I don't know of any software that does this, but there probably
is something on the market.

The other option (and the one that's already been recommendend) is the
more common approach, which is to use Web Services on the Java end and
the .NET side to marhsall the calls. This was (at least in part) the
whole point of web services and XML itself- to allow disjoined systems
the ability to communicate with one another.
 
W

Wayne Citrin

Jim --

You can call Java classes from C# through our Java/.NET interoperability
tool, JNBridgePro. See www.jnbridge.com for more information, or contact me
for details.

JNBridgePro is one of the solutions featured in the Patterns and Practices
book mentioned below.

Regards,
Wayne
____________________________________

Wayne Citrin
JNBridge, LLC
citrin@NoSpam_jnbridge.com (remove anti-spam text in e-mail before replying)
www.jnbridge.com
Spanning the Worlds of Java and .NET
____________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top