Solved

Native struct

Posted on 1997-07-07
2
343 Views
Last Modified: 2006-11-17
hi,

I have following question. It would be very nice, if someone can help me.
So I must integrate  native codes in my applet. How can i integarte a complex structure in my java-program.
So i have a complex data type like this
struct XXX(int a,
           *char b,
           *complex_struct c....)
complex_struct is a complex data type like a struct.

So that is not a problem if a have a complex data type
like byte[]. I can translate this to HArrayByte, but what
sould I do, if I have a complex struct like above?

Thanks for any help.

Regards,
Benediktus B. Thie
0
Comment
Question by:irian
2 Comments
 
LVL 2

Expert Comment

by:webster030697
ID: 1222778
I'm not sure how far this will go to answer your question, but hava a look at:

http://www.sd.monash.edu.au/~scott/java/Generic/Lectures/Lecture10/

There are two pages there (3, 4)that deal with native methods, and their implementation.

Good luck!
0
 

Accepted Solution

by:
bare earned 100 total points
ID: 1222779
Hi Irian,
I'll assume that you already know how to handle native methods, otherwise look for it in http://java.sun.com/docs/books/tutorial/native1.1/index.html
This is the best place to learn about how to integrate native code with java code.
Now, to the point, let's say you want to call a native function written in C and you want to send to the function a struct value. What you need to do in your Java code is to initiate a Class that will have all and only the contents of the struct. In you example, what you should do is:
public Class XXX {  // this class is jdk1.1 compatible due to the
   public char c;   // use of inner-classes, but you can avoid it
   public class complex {
      public int x,y;
   }
}

Sending this class after setting the value for the veriables is just like sending a struct value.
When using native methods you need to use the "javah" tool. looking at the .h file you'll see that your .class file is translated to a "struct-like" in the .h file and so a native function can access the java code ....
(this is a brief on the case ....)
Hope I've been helpful.
Have fun,

bare.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
expectj telnet failing 5 45
tomcat startup error 5 104
jsp login check 12 43
jsp CRUD operations with and without prepared statement also hibernatge 1 11
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question