Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how to use classes programmed in ADA in a class programmed in JAVA?

Reply
Thread Tools

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

 
 
ogalve
Guest
Posts: n/a
 
      02-06-2007
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

 
Reply With Quote
 
 
 
 
Chris Uppal
Guest
Posts: n/a
 
      02-06-2007
ogalve wrote:

> 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


 
Reply With Quote
 
 
 
 
Chris Uppal
Guest
Posts: n/a
 
      02-06-2007
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



 
Reply With Quote
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      02-07-2007
Chris Uppal wrote:
> 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/f...at/jgnat-1.1p/

Arne

 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
ASP.NET Error redirect then use Back button (or programmed button) phancey ASP .Net 3 02-23-2008 03:51 PM
Embedded languages based on early Ada (from "Re: Preferred OS, processor family for running embedded Ada?") Colin Paul Gloster VHDL 48 04-10-2007 10:31 AM
Is cisco IOS programmed in forth? sqrfolkdnc Cisco 16 09-20-2005 05:44 PM
Re: Ada performance (was No call for Ada ) Joona I Palaste Java 0 02-15-2004 07:17 PM



Advertisments