[java] Mixing Java and C++.

Started by
2 comments, last by Grasshopper 23 years, 6 months ago
I''m working with a group of people on a project and I want to use Java as the GUI but everone else is using C++ for their part iof the code. How can I mix their code with mine which will be used for the user interface. Is their anywhere I can find a tutorial on this?
Advertisement
you can use the java naitive interface...I dont know where you can find tutorials but there are quite a few books on it

I wish there was a button on my monitor to turn up the intellegince.
Theres a button called 'brightness' but it doesn't work
I wish there was a button on my monitor to turn up the intellegince. Theres a button called 'brightness' but it doesn't work
Hi,

I like Java and normally recommend mixing it but if you are the only person on your team using Java and all the others use C++ this seems to a recipe for failure. If one splits up a project in C++ and Java it should be done with a sound division, not just because one programmer prefer one over the other.

If I was you I would accept it and write your GUI in C++. If you use Windows you can get some pretty good dialog editors and such that can make development fairly fast. Writing a C++/java interface will certainly take longer time to do and it complicates the project unneccesarily.

Jacob Marner
Jacob Marner, M.Sc.Console Programmer, Deadline Games
I would have to agree with the last statement. It may make sense to use Java and C++ for a multi-tiered system, where different layers are built in either Java or C++. An example would be a rendering engine written in C++ using a scripting engine written in Java (ala The NOD engine from Nihilistic or the Unreal Engine from Unreal).

But building different components of the same ''layer'' is asking for trouble. One of the design goals of using Java with C++ is to carefully control how much goes through JNI (for performance reasons). A component of a GUI interface is going to be accessed constantly from the primary engine and possible from the other components - meaning a lot of lost performance going through he JNI interface. In the case of the scripting engine the lost performance is compensated by the increased ease of developing the game, but I can''t see any benefit you get from mixing languages at the GUI level. Unless there is some benefit from using Java for your GUI component you are wasting performance in your game engine.

On top of that you must consider that mixing languages in a project automatically increases the complexity and difficulty of the work. Why would you make your game more difficulty and more time consuming to build? The issue will be even more critical if this is a hobbyist development or your team members are communicating over distance. Again, you need to have a very compelling reason before taking this route.

But you might have already considered these issues and there may be some reason for using Java in this instance. If so here is the link to the FAQ portion on using C++ and Java to get you started.

http://games.cpbinc.com/faq/cc.asp#t5

This topic is closed to new replies.

Advertisement