javaarchlinuxqt-jambi

QtJambi example not executing


I'm trying to compile and run the tooltip code from this tutorial. I obtained QtJambi from my package manager (the package is qtjambi-beta from AUR), which installed it into the directory /opt/qtjambi-beta/. In particular, the qtjambi-4.7.0.jar file is located at /opt/qtjambi-beta/qtjambi-linux64-community-4.7.0/qtjambi-4.7.0.jar.

Now, I made a folder called qtpractice and put the example in there under the name JambiApp.java. The code I put into it was exactly as follows (following the example I linked):

package qtpractice;

import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QWidget;

public class JambiApp extends QWidget {

     public JambiApp() {
        setWindowTitle("Tooltip");
        setToolTip("This is QWidget");
        resize(250, 150);
        move(300, 300);
        show();
    }


    public static void main(String args[]){
        QApplication.initialize(args);
        new JambiApp();
        QApplication.exec();
    }
}

I compiled it with javac qtpractice/*.java -cp /opt/qtjambi-beta/qtjambi-linux64-community-4.7.0/qtjambi-4.7.0.jar, which worked fine. I then tried to execute it with java qtpractice.JambiApp, and I got the following error:

Error: Could not find or load main class qtpractice.JambiApp

EDIT: Based on some advice from the comments, I tried this command instead: java -cp /opt/qtjambi-beta/qtjambi-linux64-community-4.7.0/qtjambi-4.7.0.jar qtpractice.JambiApp . When I did this, I got the following error again:

Error: Could not find or load main class qtpractice.JambiApp

What did I miss? From what I can tell, I did everything necessary to make it execute.


Solution

  • You need to include all jars Qt Jambi needs in classpath.

    This can be done on CLI with command similar to

    java -cp /opt/qtjambi-beta/qtjambi-linux64-community-4.7.0/qtjambi-4.7.0.jar:/opt/qtjambi-beta/qtjambi-linux64-community-4.7.0/qtjambi-linux64-gcc-4.7.0.jar:. qtpractice.JambiApp
    

    When compiling, native jar does not need to be present, as the native libraries are just for Jambi classes to be able to use Qt.