How to use Java to talk to Fortran program?

S

Shawn

Hi,

I am a Java programmer. Recently I need to build a Java gui which calls
Fortran programs doing computation. Could anybody give me some
suggestions how to get start with this?

Thank you very much.
 
O

opalpa opalpa

You can invoke Fortran executable from Java like any other executable.

If you're in an environment that blends C with Fortran you can JNI to C
and call Fortran from there.

Invoking executables is less work than JNI.


Opalinski
(e-mail address removed)
http://www.geocities.com/opalpaweb/
 
C

Chris Uppal

Shawn said:
I am a Java programmer. Recently I need to build a Java gui which calls
Fortran programs doing computation. Could anybody give me some
suggestions how to get start with this?

Keep it as simple as you possibly can. If you can meet your requirements by
running the Fortran code as an external program and communicating with it via
either or both of files or stdin/stdout then do that.

-- chris
 
S

Simon Brooke

Shawn ('[email protected]') said:
Hi,

I am a Java programmer. Recently I need to build a Java gui which calls
Fortran programs doing computation. Could anybody give me some
suggestions how to get start with this?

OK, approaches.

(i) Have the Fortran program open a port and listen on it. Have the GUI
talk to the Fortran program on that port. You'll need to develop a
protocol, and parsing the protocol at both ends is an overhead, but it
saves an awful lot of tricky code. This is what I would do because it
looks easiest to me.

(ii) Use a Fortran compiler that compiles to JVM. University of Tenesse
have one called f2j, but I don't know how complete it is:
http://icl.cs.utk.edu/f2j/overview/index.html

(iii) Use the GNU C compiler to compile Fortran for the JVM. Sounds
bizarre, but should be possible as GCC has JVM as one of the processors it
supports and Fortran 77 as one of the languages it supports.

(iv) Craft glue code using JNI. This is the 'official' way of doing it, but
my guess is that it would quickly get dark and dirty.
 

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

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top