aspose file tools*
The moose likes Java in General and the fly likes jar to native dll Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "jar to native dll" Watch "jar to native dll" New topic
Author

jar to native dll

rizzwan khan
Greenhorn

Joined: Dec 01, 2010
Posts: 3
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

Joined: Oct 27, 2005
Posts: 19722
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
rizzwan khan
Greenhorn

Joined: Dec 01, 2010
Posts: 3
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

Joined: Oct 27, 2005
Posts: 19722
    
  20

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

Joined: Dec 01, 2010
Posts: 3
Thanks mate.. I will look into the JNI and start working on it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jar to native dll