configure Qt Jambi (os x)

Mac OSX command line development

install

install JDK and Qt Jambi Jambi

unzip down file, then

$ ./qtjambi.sh

安装用如下命令行,它会将一系列动态库dylib拷入系统目录中

$ sudo sh installer-osx.sh
HelloWorld.java
import com.trolltech.qt.gui.*;
public class HelloWorld{ 
public static void main(String args[]) { QApplication.initialize(args); 
QPushButton hello = new QPushButton("Hello World!"); hello.resize(120, 40); 
hello.setWindowTitle("Hello World"); 
hello.show(); 
QApplication.execStatic(); //<-- change this line
QApplication.shutdown(); 
}}

Code for Hello World
in Jambi 4.8 use execStatic() instead of exec()

compile

configure environment variables, making javac find jambi library.
in ~/.bash_profile add these codes, then register system

export JAVA_HOME=`/usr/libexec/java_home`
export JAMBI_LIBRARY_PATH=/Users/your_user_name/Documents/other-workspace/qtjambi-4.8.6
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:${JAMBI_LIBRARY_PATH}/qtjambi-native-macosx-gcc-4.8.6.jar:${JAMBI_LIBRARY_PATH}/qtjambi-4.8.6.jar:${JAMBI_LIBRARY_PATH}/qtjambi-util.jar:${JAMBI_LIBRARY_PATH}/qtjambi-designer-4.8.6.jar

generate HelloWord.class

javac HelloWorld.java
run
java -XstartOnFirstThread HelloWorld

Note: When running a Qt Jambi application on Mac, it is necessary to pass the -XstartOnFirstThread argument to the Java executable.

if cannot find jambi library, you can use the -classpath parameter to specify the path of the jambi library to force the specified path.

export JAMBI_LIBRARY_PATH=/Users/pro/Documents/other-workspace/qtjambi-4.8.6
export CP=${JAMBI_LIBRARY_PATH}/qtjambi-4.8.6.jar:${JAMBI_LIBRARY_PATH}/qtjambi-util.jar:${JAMBI_LIBRARY_PATH}/qtjambi-designer-4.8.6.jar
java -XstartOnFirstThread -classpath $CLASSPATH:$CP HelloWorld

offical download
Qt Jambi Wiki
tutorial

Reference:
http://www.jianshu.com/p/6d7f8a560169

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容