Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
ogalve - 06 Feb 2007 17:26 GMT
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
Chris Uppal - 06 Feb 2007 18:09 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.