Using Java from C ++

As a C ++ developer, I sometimes come across Java libraries such as iText , Batik , JasperReports and JFreeChart . In each case, the equivalent cross-platform C ++ libraries seem much less mature, much more expensive or inaccessible.

Can I use these Java libraries from my C ++ application for reporting, charting, etc.? If so, what is the best approach to this?

  • Use JNI to embed JVM in my application?
  • Use GCJ to compile Java libraries into native code?
  • Any other integration method that I don't know about?
  • Refuse, since invoking a Java library from C ++ will be too complicated to be practical, and instead invest your efforts in finding C ++ libraries?
+5
source share
1 answer

A less complicated integration method is the old-school UNIX approach: run a small Java program that performs the task you need and communicates with it via STDIN / STDOUT.

This may not be possible in all cases, but it is definitely for cases such as PDF, SVG, reports and scheduling, which are mainly associated with the creation of separate documents for saving or display.

log4j, slf4j, JUL .., ! , Java , , ++. .

+3

All Articles