AllExperts > Experts 
Search      

Java

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Java Answers
Question Library

Ask a question about Java
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Artemus Harper
Expertise
I have a BS in computer science and am working towards a Masters degree.

Experience
I have experience in Core Java, good background in Java swing/gui, some experience with JNI, Java reflection, and Java java.nio.* knowledge of Java bytecode and annotations. Basics in c++ and c#
 
   

You are here:  Experts > Computing/Technology > Focus on Java > Java > JNI

Topic: Java



Expert: Artemus Harper
Date: 6/26/2008
Subject: JNI

Question
Sir ,
I want to Access Windows Core (Kernel) DLL's in java
program please help with a complete step by step way,
please use an example.
    Thanks.

Answer
You have a couple of options... Java only supports calling native code if the name of the function is in the format it expects. For this reason, you would need to create a dll, and have it call the kernel function you want.

You can use an existing utility library that does this. E.g.
http://johannburkard.de/software/nativecall/

Or you could do it your self. To do this your self, simply create a method with the native keyword that has the parameters of the function you want to call. Then run javah on the class(es) that have the native methods. This will generate a .h file with the prototype definitions. Then create a .c file that implements those methods and calls the native call you want to do. Then compile it with a c compiler (to a dll) then load that dll in your java code with the System.load(String) method. You can then call the native method and it will invoke the kernel code.

I would probably suggest the first possibility. The website includes examples.

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.