Solved

Native struct

Posted on 1997-07-07
2
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Suggested Courses

738 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