Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > change default package in a JNI class

Reply
Thread Tools

change default package in a JNI class

 
 
Bura Tino
Guest
Posts: n/a
 
      09-04-2003
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


 
Reply With Quote
 
 
 
 
Gordon Beaton
Guest
Posts: n/a
 
      09-04-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JNI thread vs. native thread vs. JNI call bgabrhelik Java 0 09-29-2009 03:33 PM
Re: JNI: Error loading DLL from JNI DDL vasanth Java 0 01-25-2005 11:03 AM
Re: JNI: Error loading DLL from JNI DDL vasanth Java 0 01-25-2005 11:01 AM
Porting JNI Windows under JNI LINUX + Wine ? Pasturel Jean-Louis Java 5 03-03-2004 07:50 PM
IBM's JNI fails where Sun's JNI works Alex Hunsley Java 4 11-04-2003 10:34 AM



Advertisments