You are not logged in.

#1 2009-09-10 08:31:25

armageddon09
Member
Registered: 2009-02-17
Posts: 37

Qt applications in Java?

How do I develop Qt applications in Java? I'm using KDEmod.

Offline

#2 2009-09-10 08:42:05

Aprz
Member
From: Newark
Registered: 2008-05-28
Posts: 277

Re: Qt applications in Java?

I'm guessing this.

Offline

#3 2009-09-10 09:28:21

armageddon09
Member
Registered: 2009-02-17
Posts: 37

Re: Qt applications in Java?

Aprz wrote:

I'm guessing this.

Ok so I installed QtJambi from AUR. I wrote this program:

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

Then I compile it:

┌─[armageddon @ dragonzden]
└─[~/Programming/Qt]> javac HelloWorld.java
HelloWorld.java:5: cannot find symbol
symbol  : variable QApplication
location: class HelloWorld
                QApplication.initialize(args);
                ^
HelloWorld.java:6: cannot find symbol
symbol  : class QPushButton
location: class HelloWorld
                QPushButton hello = new QPushButton("Hello World!");
                ^
HelloWorld.java:6: cannot find symbol
symbol  : class QPushButton
location: class HelloWorld
                QPushButton hello = new QPushButton("Hello World!");
                                        ^
HelloWorld.java:10: cannot find symbol
symbol  : variable QApplication
location: class HelloWorld
                QApplication.exec();
                ^
4 errors

How do I solve this problem ?

Offline

#4 2009-09-10 10:57:03

Aprz
Member
From: Newark
Registered: 2008-05-28
Posts: 277

Re: Qt applications in Java?

I am not playing with this at the moment (haven't programmed in Java in about a year, haha), but right off the bat, I notice you aren't importing anything, and I don't believe Java will all of the sudden do it by itself (from what I recall, it just imports java.lang by default - nothing else) so I believe you need to insert this at the top of your hello world program:

import com.trolltech.qt.gui.*;

Makes sense looking at the errors the compiler is spewing out, but this is only my educational guess from briefly and very briefly looking at this.

Last edited by Aprz (2009-09-10 11:00:45)

Offline

#5 2009-09-10 12:47:40

armageddon09
Member
Registered: 2009-02-17
Posts: 37

Re: Qt applications in Java?

Aprz wrote:

I am not playing with this at the moment (haven't programmed in Java in about a year, haha), but right off the bat, I notice you aren't importing anything, and I don't believe Java will all of the sudden do it by itself (from what I recall, it just imports java.lang by default - nothing else) so I believe you need to insert this at the top of your hello world program:

import com.trolltech.qt.gui.*;

Makes sense looking at the errors the compiler is spewing out, but this is only my educational guess from briefly and very briefly looking at this.

Thanks for the reply. I did as you said. Now I'm getting this:

┌─[armageddon @ dragonzden]
└─[~/Programming/Qt]> javac HelloWorld.java
HelloWorld.java:1: package com.trolltech.qt.gui does not exist
import com.trolltech.qt.gui.*;
^
HelloWorld.java:6: cannot find symbol
symbol  : variable QApplication
location: class HelloWorld
                QApplication.initialize(args);
                ^
HelloWorld.java:7: cannot find symbol
symbol  : class QPushButton
location: class HelloWorld
                QPushButton hello = new QPushButton("Hello World!");
                ^
HelloWorld.java:7: cannot find symbol
symbol  : class QPushButton
location: class HelloWorld
                QPushButton hello = new QPushButton("Hello World!");
                                        ^
HelloWorld.java:11: cannot find symbol
symbol  : variable QApplication
location: class HelloWorld
                QApplication.exec();
                ^
5 errors

Offline

#6 2009-09-10 17:03:03

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: Qt applications in Java?

maybe your qtjambi package installed the files in a non-standard path and now java isn't aware of it.

cheers
Barde

Offline

#7 2009-09-10 20:36:10

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,563

Re: Qt applications in Java?

Just so you know, Jambi will not be worked on any more past Qt 4.5. It might not be a good choice for anything but fooling around, for that reason.

Offline

#8 2009-09-11 02:26:40

armageddon09
Member
Registered: 2009-02-17
Posts: 37

Re: Qt applications in Java?

Thanks for that info. Just found out about that. It seems like using QtJambi will be a waste of time. I should just use Swing.

Offline

#9 2009-09-13 05:17:27

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,563

Re: Qt applications in Java?

Or SWT smile

Offline

#10 2009-09-23 01:38:50

dalingrin
Member
Registered: 2009-03-18
Posts: 128

Re: Qt applications in Java?

This probably won't be a popular response but if you want to use Qt then I'd suggest just using C++. It really won't be that hard to learn as you go since you know Java/OOP.

Offline

#11 2009-09-23 02:47:27

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,563

Re: Qt applications in Java?

And no one forces you to do the """""real""""" (heavy quotes lol) programming in C++, you could just do the GUI in it.

Offline

#12 2009-09-23 15:03:43

dalingrin
Member
Registered: 2009-03-18
Posts: 128

Re: Qt applications in Java?

Ranguvar wrote:

And no one forces you to do the """""real""""" (heavy quotes lol) programming in C++, you could just do the GUI in it.

Very true.

Offline

#13 2010-07-31 11:24:59

fiinix
Member
Registered: 2009-12-07
Posts: 75

Re: Qt applications in Java?

Ranguvar wrote:

Just so you know, Jambi will not be worked on any more past Qt 4.5. It might not be a good choice for anything but fooling around, for that reason.

Hey, I like fooling around. And I have the exact same problem as armageddon09 had. Now since I like Qt and the only programming language I know is a little bit of Java and I don't really wanna learn anything else (no matter how small the step to C++/C# would be), I would really like to be able to use QtJambi.

Heller_Barde wrote:

maybe your qtjambi package installed the files in a non-standard path and now java isn't aware of it.

How do I make Java (javac) aware of Jambi?

Offline

Board footer

Powered by FluxBB