aspose file tools*
The moose likes Java in General and the fly likes Accesing a JAR from .Net framework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Accesing a JAR from .Net framework" Watch "Accesing a JAR from .Net framework" New topic
Author

Accesing a JAR from .Net framework

Juan Francisco Paulini
Greenhorn

Joined: Oct 02, 2006
Posts: 3

Hi all,
If I have a JAR file, including several java classes, there is any web to call this classes/methods throught web services?

I�m trying use a .NET application (custom made) to interface a Java application (out-of-the-box package), and the latest one have a JAR API, but developers wanted to access it v�a Microsoft framework (they don�t know what they miss ;-) )

My first idea was to make a applet to wrapp Java functionality, but it does not seems to be smart.

Thanks a lot in advance.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14149
    
  18

Why did you want to make an applet to wrap the JAR file; how would make that calling the Java code from .NET possible?

If you want to be able to call the code as a web service, you'll need to setup a webserver (Tomcat or a J2EE application server), write some wrapper code, and deploy your wrapper code as a web service on Tomcat or the J2EE app server.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
I don't know much about .NET, but I believe you can include C or C++ code in .NET applications. So you can call code in your Java Jar directly, by firing up a JVM within your .NET application's process, using Java Invocation API, then use Java Native Interface (JNI) to call Java methods from your C/C++ code. This approach should give good performance and gives you good control over the life-cycle of the JVM running your Java. Another benefit is that you do not have the overheads of running a Java Web server, application server or whatever. On the other hand, it is moderately difficult to implement the code. It also couples your .NET and your Java code quite strongly.

If performance is not desperately important, or avoiding coupling is important, you should consider one of the out-of-process ways of talking between Java and .NET. Web services, XML RPC, CORBA, sockets...
[ October 02, 2006: Message edited by: Peter Chase ]

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Juan Francisco Paulini
Greenhorn

Joined: Oct 02, 2006
Posts: 3

Hi Jesper,
Yes, when I mean applet, I thought of using a web server. Sorry if I wasn�t clear.

Hi Peter,
Do you have some sample code for doing that? I think I don�t quite understand what you mean. Where can I find C code for JVM invocations?

I would try to use Web Services for doing that integraton, but I�m trying to find a smarter solution that to write a very specific wrapper, that I�ll have to modify if the JAR file changes..

Thanks both for your replies.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
STFW! Google for the things I mentioned: Java Invocation API, Java Native Interface (JNI).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accesing a JAR from .Net framework