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

    Exclamation How to build jar with JNI

    Greetings,

    I now understand how JNI works, but I have a problem building the project.
    The project runs on run project using Netbeans 6.8, but as I look into the .jar through WinRar - the dll file isn't found.
    Plus, running the jar file won't even display the JFrame.

    I have done two ways,
    1) Make a folder wherein all the header and source of the dll are found inside the project folder;
    2) Copy only the dll and place it into the project folder.

    In what way would this be solved?

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

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    Don't know anything about a project folder.
    I think that the .dll files have to be outside the jar file as they are probably loaded by the OS vs read from the classpath.

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

    Default

    Thanks...
    But is there a way to insert the .dll into the .jar file?
    I would appreciate it if that would be possible.

    Thanks.
    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 offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    is there a way to insert the .dll into the .jar file
    Yes use the jar command with the u option.

    Why do you want a .dll file in a jar file?

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

    Default

    For additional security purposes and more easier deployment.
    How would I do that, I am building the project using Netbeans 6.9 (just converted the project from Netbeans 6.8)
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    Sorry, I have no idea on how to use your IDE.

    What use is the .dll in the jar file? The OS won't look for it there.
    Do you plan to copy it out of the jar file so the OS can find it?

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

    Default

    The .dll is used for JNI through C in which manipulates the Windows Registry.
    I find it somehow wrong if the .dll is displayed within the directory where the .jar is found.
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    I find it somehow wrong if the .dll is displayed within the directory where the .jar is found
    What does "wrong" mean? There are errors or you don't like it.

    Have you tried executing the program when the .dll is only inside the jar and not visible to the OS on any of its PATHs? Does it work?

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

    Exclamation

    Quote Originally Posted by Norm View Post
    What does "wrong" mean? There are errors or you don't like it.
    Well if the .dll isn't found inside the directory, the .jar won't run properly or nothing will happen at all.

    Quote Originally Posted by Norm View Post
    Have you tried executing the program when the .dll is only inside the jar and not visible to the OS on any of its PATHs? Does it work?
    Never yet, I don't know how to include the .dll in the build using Netbeans 6.9
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    I expect Netbeans doesn't include it in the jar for the same reason it doesn't include other jars in the jar. It doesn't make sense to.
    I expect it sticks it either in the jars in the lib directory of the dist folder, or something along those lines.

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

    Exclamation

    Quote Originally Posted by Norm View Post
    What does "wrong" mean? There are errors or you don't like it.

    Have you tried executing the program when the .dll is only inside the jar and not visible to the OS on any of its PATHs? Does it work?
    Quote Originally Posted by Tolls View Post
    I expect Netbeans doesn't include it in the jar for the same reason it doesn't include other jars in the jar. It doesn't make sense to.
    I expect it sticks it either in the jars in the lib directory of the dist folder, or something along those lines.
    Ok, then I'll stick to placing the .dll in the same directory of the .jar file.
    Thread solved.
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    Netbeans creates a dist directory.
    It's that directory you should be deploying.
    It should have everything needed to run the app.
    I have no idea whether there are additional steps involved with JNI libraries, though.

Similar Threads

  1. ant build
    By sardare in forum New To Java
    Replies: 4
    Last Post: 04-02-2009, 10:02 PM
  2. Unable to build
    By jkeller in forum Eclipse
    Replies: 1
    Last Post: 01-15-2009, 06:56 PM
  3. various stuffs to build GUI
    By Devi in forum AWT / Swing
    Replies: 1
    Last Post: 12-01-2008, 07:04 PM
  4. clean and Build
    By bhanu in forum Eclipse
    Replies: 3
    Last Post: 07-03-2008, 01:13 PM
  5. Replies: 0
    Last Post: 06-11-2008, 01:56 PM

Posting Permissions

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