Calling a JAVA DLL from Fortran

Calling a JAVA DLL from Fortran

I am trying to call a JAVA DLL from Fortran but I cannot find any tutorial on this issue. I wonder anyone has any experience? Thanks

13 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

>>...I am trying to call a JAVA DLL from Fortran but I cannot find any tutorial on this issue. I wonder anyone has any experience...

I'm not 100% sure that it is possible to call Java Dll directly from Fortran application, like:

1. FortranApp -> JavaDll

But, if you create an additional layer as C/C++ Dll it is possible, like:

2. FortranApp -> CCppDll -> JavaDll

Or, if you create an additional layer as Java-based COM interface it is possible as well, like:

3.1 FortranApp -> JavaCOMDll -> JavaDll
or
3.2 FortranApp -> JavaCOMDll

I can look at my CD archives if you need some generic codes for solution 2, that is CCppDll -> JavaDll, and confirm if you really need it.

Hi,

Do you mean to call java methods class wrapped into some dll file or are you refering to some part of JVM installation implemented on windows as a dll file?

Hi Sergey

Thanks for your answer. For sure it will be great if you can show me how to do it by method 2.

I am trying to implement some new features to a fortran-written program and the new codes are written in Java. If there is a way to communicate between Fortran and Java through dll, then I don't need to re-write the Java code into C or Fortran which definitely saves time.

Quote:

Sergey Kostrov wrote:

>>...I am trying to call a JAVA DLL from Fortran but I cannot find any tutorial on this issue. I wonder anyone has any experience...

I'm not 100% sure that it is possible to call Java Dll directly from Fortran application, like:

1. FortranApp -> JavaDll

But, if you create an additional layer as C/C++ Dll it is possible, like:

2. FortranApp -> CCppDll -> JavaDll

Or, if you create an additional layer as Java-based COM interface it is possible as well, like:

3.1 FortranApp -> JavaCOMDll -> JavaDll
or
3.2 FortranApp -> JavaCOMDll

I can look at my CD archives if you need some generic codes for solution 2, that is CCppDll -> JavaDll, and confirm if you really need it.

Hi

I've never used Java so I am not sure about your question. The situation is I am trying to implement a new feature into a Fortran-written program and the codes for new feature is written in JAVA. So I need some tutorial about how to call a JAVA DLL from Fortran program. Thanks a lot for your reply. Maybe I didn't explain my question clearly.

Quote:

iliyapolak wrote:

Hi,

Do you mean to call java methods class wrapped into some dll file or are you refering to some part of JVM installation implemented on windows as a dll file?

Hi,
I understood your question and I will try to find some information about the calling java code from fortran
Here link about the JNA interface,but this is related to calling fortran from java:
http://javaforge.com/wiki/66061

You can find info about the calling fortran from java,but reverse operation is not very well documented.

>>>I've never used Java so I am not sure about your question. The situation is I am trying to implement a new feature into a Fortran-written program and the codes for new feature is written>>>

Is this java feature related to scientific or math related code?Can not you simply port that feature to fortran?

I agree. I do find some about the reverse one but not call java from fortran

Quote:

iliyapolak wrote:

You can find info about the calling fortran from java,but reverse operation is not very well documented.

Since it's alrady written in JAVA, it would save time if Fortran can directly call Java. If it is not doable, then we might divert to plan B to re-write the codes in C/C++ or fortran.

Quote:

iliyapolak wrote:

>>>I've never used Java so I am not sure about your question. The situation is I am trying to implement a new feature into a Fortran-written program and the codes for new feature is written>>>

Is this java feature related to scientific or math related code?Can not you simply port that feature to fortran?

>>...For sure it will be great if you can show me how to do it by method 2...

I'll take a look and let you know as soon as I find that small test project on my CDs ( it was almost 6 years ago... ).

I would like to suggest you waiting for Sergey's input and if this won't help, try to port the code to fortran.Is java code highly object-oriented?

There are two news and, as usual, one is good and another one is not good. I found sources in 2006 CD archives but, unfortunately, it is not applicable for your case.

Just in case, a zip file with sources is attached and the test demonstrates how a C/C++ DLL could be called from a Java applet: Java applet -> C/C++ DLL

Note: Java NI stands for Java Native Interface

Attachments: 

AttachmentSize
Download javanitest.zip129.68 KB

Leave a Comment

Please sign in to add a comment. Not a member? Join today