Results 1 to 16 of 16

Thread: JNI Help

  1. #1
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Exclamation JNI Help

    I have researched about this JNI thing over the net.

    I am currently developing a program to make the computer manipulate the Windows regristry. The maniplation in a way that the program can enable/disable accessing the control panel, task manager, a particular drive, etc.

    I have research that c++, c#, visual basic can manipulate the windows registry but the main language of the program is Java.
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,165
    Rep Power
    20

    Default

    And?
    Your question is?

  3. #3
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    Is it possible that it could be possible that through JNI, we could manipulate the Windows Registry.

    And how?
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,755
    Rep Power
    25

    Default

    Yes. Java could call another program that is able to change the Registry. JNI could be the way to do it.

    Another way would be to call a program using the Runtime & Process classes and pass that program instructions on the commandline.

  5. #5
    fxRichard is offline Member
    Join Date
    Dec 2008
    Posts
    64
    Rep Power
    0

    Default

    Correct, Java does not have this level of control. I have code that does exactly this, your best bet is to do as I did and write your own custom DLL file, package it in with your application and call the methods via JNI.

  6. #6
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    Ok. Thanks for the suggestions.
    But I am having a hard time understanding how JNI really works or coded.

    Can you help me to fully understand the basics of JNI programming?
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  7. #7
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Quote Originally Posted by chyrl View Post
    Can you help me to fully understand the basics of JNI programming?
    If you're not very fluent in C/C++ it can be difficult. I remember that for me it took several tutorials and a bit of intense study before I thought that I "got it". Keep at it!

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,165
    Rep Power
    20

  9. #9
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    Whew. This tutorial is the one i'm having a hard time understanding it.
    But if it's the only way around, I have to read between the lines. :)

    Are there any tutorial on how to write a JNI code using IDE (Netbeans 6.8 or Eclipse 3.4.1)?
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  10. #10
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    Is there an easier comprehensive tutorial about JNI?
    I still have a hard time understand the logic of JNI.
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  11. #11
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,755
    Rep Power
    25

    Default

    I'm not sure there is logic for JNI. I think its mostly cookbook: Read and follow instructions.

  12. #12
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    Ok. But can you guide me step by step on how to create a program using JNI?
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  13. #13
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,725
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by chyrl View Post
    Ok. But can you guide me step by step on how to create a program using JNI?
    Is Google down in your part of the world?

    kind regards,

    Jos

  14. #14
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by chyrl View Post
    Ok. But can you guide me step by step on how to create a program using JNI?
    Honestly, you're asking a heck of a lot here, and I strongly doubt that anyone really has the time to walk you hand in hand through something as complex as this. Most of us have lives/jobs/families, etc... If this is what you really need, consider paying for a tutor. Otherwise do what the rest of us did: get lots of your caffeinated beverage of choice and dedicate several days to working through the tutorials til you eventually work this thing out.

    Please feel free to come back though if you have a specific question.

  15. #15
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    I know it may seems a lot for this thread.
    But I was asking the general steps on how to create a JNI program.
    I am having a hard time understanding the JNI API.
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  16. #16
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,725
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by chyrl View Post
    I know it may seems a lot for this thread.
    But I was asking the general steps on how to create a JNI program.
    I am having a hard time understanding the JNI API.
    It's not so hard: start by writing a little class that has a 'native' method declaration. Compile the class (using javac) and run javah on your .class file (your actual class). Javah generates a .h (header) file for C or C++. It contains the prototype for that native method. You have to implement that method in a .c or .cpp (or whatever) file.

    You compile that file and link it; you have to create a .so file (or .dll file). So now you have a compiled .java file: a .class file that has a reference to a native method. The compiled method is stored in your .so (or .dll) file. All you have to do is load that library with the System.loadLibrary( ... ) method and you're in business.

    kind regards,

    Jos

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •