how to use classes programmed in ADA in a class programmed in JAVA?

O

ogalve

Hello!

I have a lot of "classes" in ADA, and I want to make a program in JAVA
using this classes.
For example, I have the implementation of a generic list in ADA, and I
want to use it in an interactive program that simulate the working of
generic list, a webpage where the user put the value and see how the
list manage the value.

1. Can I use code in Ada in an applet? (with import or something like
this)
2. How can I do it?

Thank you for read my post, I hope you can help me
 
C

Chris Uppal

ogalve said:
1. Can I use code in Ada in an applet? (with import or something like
this)

The simple answer is that you can't call Ada code from Java.

The more complex answer is that you /can/ do it, but its not at all simple, and
it won't be worthwhile unless you have a large or complicated Ada program or
library.

And for your example, it doesn't sound as if it /would/ be worthwhile.

2. How can I do it?

The less complex way is to wrap up your Ada code as a program which reads from
files or stdin, and writes to other files or stdout (which it may do already,
of course), and then use Java's Runtime.exec() or a ProcessBuilder to execute
that program.

The more complex, but also more flexible way, is first to find out how to
invoke your Ada code from C or C++. Then use Java's JNI to invoke the C or C++
code, which in turn invokes your Ada code.

It /may/ be possible to skip the C/C++ bit, if you know how to build a DLL (or
..so library, or whatever) directly from Ada. If you can control /completely/
the names of the exported symbols and the corresponding function's calling
conventions, etc, then you can probably build a DLL which "looks" (to Java) as
if it were a normal C-built JNI DLL. That would require some understanding of
both JNI and of how Ada builds DLLs.

Lastly, if you can build general purpose DLLs in Ada (not restricted to only
being used /from/ Ada), then there are several products (some commercial, some
free) which allow Java to invoke code directly from the DLLs. In particular,
if you are targeting Windows, and if there is a way you can write COM
components in Ada, then there are products which allow you to use COM from
Java.

However, from the sound of your target application, none of those options are
relevant to you.

-- chris
 
C

Chris Uppal

?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top