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