> 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
Chris Uppal - 06 Feb 2007 18:40 GMT
I wrote:
> The simple answer is that you can't call Ada code from Java.
I completely overlooked the possibility that it might be possible to compile
Ada to Java bytecode. It seems there are products which can do that. For
instance, some links
http://www.adahome.com/Resources/Ada_Java.html
http://www.adahome.com/Tutorials/Lovelace/lovelace.htm
From a casual glance, it seems as if it might be possible to write applets
entirely in Ada.
-- chris
Arne Vajhøj - 07 Feb 2007 02:09 GMT
> I completely overlooked the possibility that it might be possible to compile
> Ada to Java bytecode. It seems there are products which can do that.
The product is called JGnat.
I can confirm that it works excellent.
Unfortunately it is not actively maintained and it may
not even be easy to get a copy of it.
I just tried googling. It is possible.
http://www.mirrorservice.org/sites/ftp.cs.nyu.edu/pub/gnat/jgnat/jgnat-1.1p/
Arne