This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jar to native dll

 
rizzwan khan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,

This is my first post on coderanch. Please let me know if am doing wrong in posting.
Well coming to the question, I have a jar(bundled collection of jars into one) and this jar doesnt have a main method. I have to convert this jar to dll and write a C code using that dll. (Native language bindings). So, are there any good tools to convert jar to native dll? I was googling and came across ikvmc but this converts jar to .Net dll. What is the difference between a normal dll and .Net dll? Can i use ikvmc to do my work? Or are there any other tools which converts jar to native dll? I see many tools that can covert jar to exe but not jar to dll. Please help me.Thanks..
 
Rob Spoor
Sheriff
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use JNI to call Java code from native programs as well as call native code from Java programs. You'll need to instantiate a JVM from the C code, then use that to do whatever you need.
 
rizzwan khan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,

Thanks for your reply. I will change my display name asap. I never used JNI am kind of new to it, i cannot do any changes to the jar. For using JNI, does the java code needs to have Native methods? Or just by adding the JNI code to C program i can call the jar without modifying(adding the native methods) the jar?
 
Rob Spoor
Sheriff
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JNI has two sides:
1) in Java there are native methods. The implementation of these methods is done in a different language, mostly C. This is the most often used form of JNI.

2) code in a different language (again, mostly C) creates its own internal JVM and uses this to create objects, call methods, etc. You don't need to change any Java code, just make sure it can be found.

You need the second form: http://java.sun.com/docs/books/jni/html/invoke.html
 
rizzwan khan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks mate.. I will look into the JNI and start working on it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic