combining Java and C++

Started by
7 comments, last by Antheus 16 years, 1 month ago
im currently taking a course called "Project IT".. which basicly is about creating some kind of application in a team... our "team" have decided to make a simple game... im in charge of the graphics and the others handle stuff like game logic and network... the problem however is that im programming in C++.. and they in Java... is there a way we can combine our code?
Advertisement
No, no an no again. You can bridge Java and C++ through C and the JNI, but it is a huge amount of work, and ridiculously hard to do in robust fashion.

And in fact, your 'team' has missed the whole point of working as a team. Get the team together as soon as possible, and work out between yourselves which language you are going to use for the project. Either one is equally feasible, although graphics is likely easier in C++ and networking easier in Java.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Quote:Original post by Dragon_Strike
im programming in C++.. and they in Java...

If you're the only team member preferring C++ you should just convert to Java.
ok... yea i guess we'll have to figure something out...

the thing is that they have only read Java..

i pretty much know the basics of Java and Swing... and i dont have the slighest idea how to do graphics in Java... which i guess means we'll have to do something else...

my largest problem here is that the course requirements was "experience with an objectoriented language"... ive done C++ for a couple of years and know it well... but everyone else knows Java... which ive only done simple applications in and dislike... if there is no way i can combine C++ and java in some project... ill have to pick up a Java book and put time that i dont rly have into that...
Quote:Original post by Dragon_Strike
ok... yea i guess we'll have to figure something out...

the thing is that they have only read Java..

i pretty much know the basics of Java and Swing... and i dont have the slighest idea how to do graphics in Java... which i guess means we'll have to do something else...

my largest problem here is that the course requirements was "experience with an objectoriented language"... ive done C++ for a couple of years and know it well... but everyone else knows Java... which ive only done simple applications in and dislike... if there is no way i can combine C++ and java in some project... ill have to pick up a Java book and put time that i dont rly have into that...


You certainly can use JNI or Swig to communicate between C++ and Java. However, I think what the other posters are mentioning is that it's possible that binding your APIs back and forth could be more work than you learning some Java and contributing to the team.

Binding between languages is a very useful technique. But, you need to be very particular about where you make the split. It has to be a better reason than language preference.
For graphics / game type stuff in java look no further than here
It is a wrapper for opengl and several other libraries.

http://lwjgl.org/
ok thx for the answers... ill pick up that java book then
Quote:Original post by Dragon_Strike
i pretty much know the basics of Java and Swing... and i dont have the slighest idea how to do graphics in Java... which i guess means we'll have to do something else...


Just let someone else work on the graphics part. If your code is properly designed (a property that does not depend on the language you are using), then there should be clear separation of game-update and rendering logic, so that shouldn't be a problem.
Quote:Original post by Dragon_Strike

the problem however is that im programming in C++.. and they in Java...


Is there a technical reason behind this?

Quote:is there a way we can combine our code?
Yes, multiple. Depends on whether it's worth it.

Quote:Project IT


Working on a project like this isn't about some perfect end result.

It's about learning first-hand how to *complete* something in a team.

This means that entire team will be most productive if they work in Java. A consequence of this is - you will need to yield. Either accept a simpler task, or work as a mentor to someone proficient in Java.

One of the biggest obstacles to team work are soloists. They know something, and they refuse to accept the reality that their contribution or expertise on that part is not worth the effort.

Let's say you get sick. Your team won't know how to build your sources. They won't be able to run your unit tests. They won't know why they are suddenly getting a 500-page error during build.

And besides, since this sounds like software oriented course, the first lesson you'll learn that getting to choose a language or API is a luxury you'll likely rarely have in your career.

So learn how to learn languages fast.

This topic is closed to new replies.

Advertisement