change default package in a JNI class

Discussion in 'Java' started by Bura Tino, Sep 4, 2003.

  1. Bura Tino

    Bura Tino Guest

    Hi,

    I'm using a java class (JMatlink) which gives access to Matlab
    functionality. All of the code (1 .java and 1 .c files) for the package is
    available. The problem is that the developer of JMatlink put the class in
    the default package which no longer works with the newer compilers. The
    original developer seems to have moved on to bigger and better things
    (re-writing Matlab in Java!) and doesn't intend to fix this issue.

    To someone who knows almost nothing about JNI (and about C development under
    windows), what are the things that I need to do move this class into a x.y.z
    package?

    Many thanks in advance!

    Bura
     
    Bura Tino, Sep 4, 2003
    #1
    1. Advertising

  2. On Thu, 04 Sep 2003 18:26:16 GMT, Bura Tino wrote:
    > I'm using a java class (JMatlink) which gives access to Matlab
    > functionality. All of the code (1 .java and 1 .c files) for the
    > package is available. The problem is that the developer of JMatlink
    > put the class in the default package which no longer works with the
    > newer compilers. The original developer seems to have moved on to
    > bigger and better things (re-writing Matlab in Java!) and doesn't
    > intend to fix this issue.
    >
    > To someone who knows almost nothing about JNI (and about C
    > development under windows), what are the things that I need to do
    > move this class into a x.y.z package?


    Since you've got the source it shouldn't be too difficult, these are
    the basic steps:

    - Add the package declarations to the Java files and recompile. See
    this page for details about directory layout and such:
    http://www.yoda.arachsys.com/java/packages.html

    - Run javah on the classes that use native methods. Make sure you
    specify the fully qualified classnames when you do this. Make sure
    you don't have the old "packageless" classfiles in sight.

    - The resulting header files will now have different (longer) names so
    you need to either change the corresponding include statements in
    the C source, or tell javah the short filenames you want it to
    generate.

    - Go through the C source and change the native method signatures to
    match those generated by javah. Basically that means adding a
    package prefix to each of the methods. A macro might come in handy,
    depending on the number of methods.

    - If there are calls to FindClass() in the C source, make sure they
    all specify fully qualified class names.

    - Recompile the C source.

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
     
    Gordon Beaton, Sep 4, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley

    IBM's JNI fails where Sun's JNI works

    Alex Hunsley, Nov 3, 2003, in forum: Java
    Replies:
    4
    Views:
    869
    Alex Hunsley
    Nov 4, 2003
  2. Pasturel Jean-Louis

    Porting JNI Windows under JNI LINUX + Wine ?

    Pasturel Jean-Louis, Feb 29, 2004, in forum: Java
    Replies:
    5
    Views:
    938
    Pasturel Jean-Louis
    Mar 3, 2004
  3. vasanth
    Replies:
    0
    Views:
    2,763
    vasanth
    Jan 25, 2005
  4. vasanth
    Replies:
    0
    Views:
    635
    vasanth
    Jan 25, 2005
  5. bgabrhelik
    Replies:
    0
    Views:
    875
    bgabrhelik
    Sep 29, 2009
Loading...

Share This Page