-2

I will be using a third party library in an application that I am currently working on.

The third party is saying that they will be providing a jar.

Since my application is c/c++ based , I prefer working with a dll.

Are there any disadvantages of using a jar with my application.

I am talking in terms of performance, dependency on JRE etc.

Please guide me as to what will be the correct way to go for.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
Mayank
  • 1,099
  • 4
  • 17
  • 44
  • 1
    A jar is an archive (a zip file) with java classes in it, you can't call these from C++ just like that. You can find some pointers [here](http://stackoverflow.com/questions/819536/how-to-call-java-function-from-c) but it won't be pretty, nor simple. – fvu Oct 07 '15 at 11:04
  • 1
    There is no correct or wrong way; just choices. JAR means Java; you'll have to interface C++ with Java. Do you know how to do that? You can link a DLL into your C++ project in Windows. The answer has little do with performance; it's about what you know how to do. – duffymo Oct 07 '15 at 11:05
  • If you have some time to solve this problem, and ***if it's legal*** for you to do so, you could have a peek at the classes in the jar (eg using jad) and translate them to C++... Won't get faster and easier than that... – fvu Oct 07 '15 at 11:13
  • @fvu, that is not an option for me :) – Mayank Oct 07 '15 at 11:36
  • 1
    "I'm building electric car. On of our subcontractors will provide us a gasonline tank, but I'd prefer a battery. What are disadvantages of using gasoline tank in my vehicle?" – el.pescado - нет войне Oct 08 '15 at 09:41

1 Answers1

0

The major disadvantage of using a JAR is that you need to write code to connect from your C/C++ code to Java. This can get rather complex, even if you use code generators for this. And a pain to debug.

Performance penalties depend on what the library is supposed to do. If it runs a CPU intensive task you might be better of using C/C++. But I don't want to start a "which language is faster" debate here ;-)

And as you mentioned: you will need to provide at least parts of the JRE to get the JAR running.

If the third party is only able to code in Java you might think about using some other means to connect your and their code. Webservices, protobuf, messaging or similar techniques might solve your problem.

Marged
  • 10,577
  • 10
  • 57
  • 99