NicolasOK, I will try to use JNI, then.Thank you for advice, I think they will help me a lot.2015-02-09 13:24 GMT+00:00 Luc Maisonobe <Luc.Maisonobe@c-s.fr>:Le 09/02/2015 14:04, SIMI Nicolas a écrit :
> Hello Everyone,
Hi Nicolas,
> I am completely new to OREKIT, but this library seems really powerful. I would
> like to use some OREKIT routines in an existing program coded in C/C++
> language.
>
> Do you think that it might be easily done? Do you have an example of such a
> use that I could inspire from in my particular case? I precise that event if I
> can program basic functions in Matlab or C/C++, I have no knowledge at all of
> programming in JAVA, PYTHON or JYTHON, and that introducing the use of Matlab
> for my purpose would make the program much more complex.
It is possible to use Orekit from C/C++ with any compiled language like
C or C++ using the standard JNI bindings (Java Native Interface). JNI is
very powerful as it support everything in Java. You can create objects,
trigger exceptions, catch exceptions, call Java or be called from Java
or both (for example if you write your own step or events handlers in
C++ and want Orekit to call them). We have used it successfully even
with Fortran integration in both directions (i.e. having chained calls
like a main program in fortran and embedded calls like fortran -> C ->
Java -> C -> fortran).
Be warned however that JNI is hard. It is really complex. The main
advices we can give you are:
- create a dedicated interface layer between you code and
Orekit
- try to transfer only primitive data types (double, integers, ...)
rather than complex structures
- beware strings must be converted du unicode
- beware arrays cannot be passed as is (i.e. you can't use a pointer
to the first element to refer to the whole array, you have to wrap
them in a real Java object array)
JNI is mainly interesting when you have lots of exchanges back and forth
between your program and Orekit. If your use case is rather a program
doing some preliminary work in C/C++, then transfer full control to
Orekit, and wait for the result, and then doing some final work
(displaying, reporting), it may be more efficient to use two separate
processes, one in C/C++ and another in Java rather than going through
the complexity of JNI.
Hope this helps,
Luc
>
> Thank you for your help,
> Nicolas
>