Java: Using *.jar libraries in my Qt Project
-
Hello People,
in the future I shall use a proprietary library - a *.jar file. The *.jar file is not open source and quite big, as I heard. At this moment I do not have access to that file. The *.jar file offers special methods, which I need.
Is there a possibility in Qt, where I can
@
#include <pathToJar> //or something wired like
#includejar <pathToJar> //or
#import <pathToJar>
@This is just a preventive question to react for further decisions just in time.
I have heard about QtJambi, but as far as I understood, this is for Java programmers, which want to use Qt? (The other way around)
Cheers Huck
-
This is more of a C++ question than Qt, but anyway, you should look at the "Java Native Interface":http://en.wikipedia.org/wiki/Java_Native_Interface
-
[quote author="dialingo" date="1310042338"]Calling a Java method from C++? No, this does not work, because C++ and Java run in different environments. [/quote]
Sure it works, you have the library running in the JRE (which you have to embed in your application using JNI) and pass calls back and forth..
-
dialingo, it will work :) as most close to Qt example project I can name Necessitas.
-
bq. Sure it works, you have the library running in the JRE (which you have to embed in your application using JNI) and pass calls back and forth..
Ok, but then the main program is Java and C++ is a subroutine doing some stuff for java and possibly calling other Java routines. But can you do
@
int main()
{
callAJavaMethod();
}@ -
dialingo, afair it is possible via jni. But not sure, it should be checked in jni documentation
-
Thank you very much. I'll engage myself in JNI.
@interested: Here you can access a detailed book about JNI: "JNI eBook":http://java.sun.com/docs/books/jni/download/jni.pdf -
sure we can done, i had already used jni, you can find jni.h file in your jdk, you better read documentation.
[quote author="dialingo" date="1310045183"]bq. Sure it works, you have the library running in the JRE (which you have to embed in your application using JNI) and pass calls back and forth..Ok, but then the main program is Java and C++ is a subroutine doing some stuff for java and possibly calling other Java routines. But can you do
@
int main()
{
callAJavaMethod();
}@[/quote]