Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Calling a JAVA DLL from Fortran

ye_T_1
Beginner
1,878 Views

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

0 Kudos
12 Replies
SergeyKostrov
Valued Contributor II
1,878 Views
>>...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.
0 Kudos
Bernard
Valued Contributor I
1,878 Views

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?

0 Kudos
ye_T_1
Beginner
1,878 Views

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.

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.

0 Kudos
ye_T_1
Beginner
1,878 Views

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.

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?

0 Kudos
Bernard
Valued Contributor I
1,878 Views
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
0 Kudos
Bernard
Valued Contributor I
1,878 Views

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

0 Kudos
Bernard
Valued Contributor I
1,878 Views
>>>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?
0 Kudos
ye_T_1
Beginner
1,878 Views

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

iliyapolak wrote:

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

0 Kudos
ye_T_1
Beginner
1,878 Views

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.

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?

0 Kudos
SergeyKostrov
Valued Contributor II
1,878 Views
>>...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... ).
0 Kudos
Bernard
Valued Contributor I
1,878 Views

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?

0 Kudos
SergeyKostrov
Valued Contributor II
1,878 Views
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
0 Kudos
Reply