Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accesing a JAR from .Net framework

 
Juan Francisco Paulini
Greenhorn
Posts: 3
Google App Engine Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15284
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Juan Francisco Paulini
Greenhorn
Posts: 3
Google App Engine Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
STFW! Google for the things I mentioned: Java Invocation API, Java Native Interface (JNI).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic