Use Qt for gui frontend for Java jar
-
Hi,
I have a Java jar for which I want to build a GUI frontend. Was wondering if I can use Qt for it?Searching around, looks like QtJambi used to be used for this purpose but looks like it is unmaintained and abandoned. So if someone wanted to use Qt IDE to build a GUI frontend and connect that to their Java Jar in 2018, what possible ways exist for one to do that?
-
It's not fun, but it is possible.
https://stackoverflow.com/questions/8850202/use-jar-file-in-c-c
I have done some C++ libraries that are used in Android front ends (so the opposite of what you are doing). Even that can be a pain with the JNI stuff.
If you had a socket, named pipe, shared memory, or some other communication method to talk to your java app then things would be much easier. Otherwise you're stuck with interfacing via something like JNI.. and it is enough work that it makes it not very fun.
-
-
@blue34 I'm so sorry I assumed you were talking C++. Just now I noticed this was in the Language Bindings section. I shouldn't assume.
Anyway you can ignore what I said above since I was assuming you were aiming at C++ for your GUI and my comments don't apply to any other language. I.e. if you used QtJambi or python or qml or anything else.
I don't know anything about QtJambi to know if it is worth using or not.
-
Since I want to use Qt Creator to design my GUI, I guess I'd be limited to using C++ for my Qt frontend, I already anticipate that.
My question was, with my frontend being in C++, how would I be communicating with my Java jar which is what the GUI would be for? My understanding was that you could use Qt Jambi previously, but looks like that project is abandoned for some time now.
-
@blue34 Oh ok, for that my previous comments stand. If you had some type of interface like I mentioned, i.e. a socket or named pipe or something, some kind of API where you could talk back and forth with your java app that would be easiest. This would be like talking to a server on the internet for example.
This would have to be by design in your java app already though or you would have to make an interface like that in the java component and one in the C++ GUI. I have done stuff like this before to have multiple interfaces to a back end. Again if it wasn't designed like that then it's probably more effort than it's worth.
If you want to directly interface with your java, check out that link I linked above to learn about interfacing C++ and java. You can use JNI to talk back and forth with C++ and java. It's a bit of a pain to do (at least imo since I'm not great with Java) but it's doable. Basically you will have to create a JNI between your java and c++ app.
-
@blue34 I haven't tried grpc before. It uses protocol buffers though which I have used and aren't a bad way of doing things.
I've never much cared for RPC mechanisms but whatever is easy for you to get implemented in the C++ side and the Java side is a decent way to do things. :)
Like I said I always go the other way... native c++ library with the front end in java (android) and ios (objc). I've been trying out djinni for that lately and it makes the jni and what not nice and easy. Wrong direction though so that won't help you out much.