Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Java: Using *.jar libraries in my Qt Project
QtWS25 Last Chance

Java: Using *.jar libraries in my Qt Project

Scheduled Pinned Locked Moved General and Desktop
9 Posts 5 Posters 9.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    huckfinn
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • L Offline
      L Offline
      loladiro
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dialingo
        wrote on last edited by
        #3

        Calling a Java method from C++? No, this does not work, because C++ and Java run in different environments.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          loladiro
          wrote on last edited by
          #4

          [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..

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DenisKormalev
            wrote on last edited by
            #5

            dialingo, it will work :) as most close to Qt example project I can name Necessitas.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dialingo
              wrote on last edited by
              #6

              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();
              }@

              1 Reply Last reply
              0
              • D Offline
                D Offline
                DenisKormalev
                wrote on last edited by
                #7

                dialingo, afair it is possible via jni. But not sure, it should be checked in jni documentation

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  huckfinn
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    TobbY
                    wrote on last edited by
                    #9

                    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]

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved