Tuesday, May 26, 2009

Java Basics Using Qt Jambi Tutorial

How To Launch The Application?

  1. Create an empty file called Main.java where your Ui_helloWorldMainWindow.java resides.

  2. Copy and paste the source code:

package helloworld;

import com.trolltech.qt.gui.*;

import helloworld.*;



* @author jun


public class Main {


* @param args the command line arguments


public static void main(String[] args) {

// TODO code application logic here


QMainWindow window = new QMainWindow();

Ui_helloWorldMainWindow ui = new Ui_helloWorldMainWindow();






Note: Your Ui_helloWorldMainWindow.java must contain: package helloworld in the first line of the source code.

  1. Create the Manifest.txt file:

Note: Manifest file should contain the libraries needed and should have a new line or carriage return after the last line.

Manifest-Version: 1.0

Ant-Version: Apache Ant 1.7.0

Created-By: 10.0-b22 (Sun Microsystems Inc.)

Main-Class: helloworld.Main

Class-Path: /path/to/qtjambi-linux32-gpl-4.4.3_01/qtjambi-4.4.3_01.jar /path/to/qtjambi-linux32-gpl-4.4.3_01/qtjambi-linux32-gcc-4.4.3_01.jar

X-COMMENT: Main-Class will be added automatically by build

  1. Make the JAR file:

    Create a directory inside your source folder according to the package name. Then, put the *.class files inside the folder.

$javac cfm [package name].jar Manifest.txt [source/folder]/*.class

$javac cfm helloworld/helloworld.jar Manifest.txt helloworld/*.class

The source folder must be the package name: “helloworld”

  1. Run the JAR file:

$java -jar Main.jar


$java -Djava.library.path=[/path/to/qtjambi/lib/]:[/path/to/qtjambi-gcc/jar] -jar [/path/to/jar]

Note: Use this if haven't included the Manifest.txt file when running JAR files created using NetBeans.

to be continued...

No comments: