Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Java and CPP?

Started by The C modest god Jul 9, 2006 at 12:22 PM 16 replies 1.8k views
Original Post
The C modest god
The C modest god
I would like to create an application that the GUI is in java, but all the logic is in regular CPP. Is this possible?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
Alpha_ProgDes
Alpha_ProgDes
Maybe (easily) with VS 2005. Other than that, it sounds like alot of complicated code to glue them together.
Beginner in Game Development?  Read here. And read here.  
SamLowry
SamLowry
If you want to do that because the logic needs to be executed efficiently and the GUI needs to be implemented rapidly, you can combine C# and C++ easily. I personally find it a *lot* easier to do GUI stuff in C# than in Java.

But Java+C++ is certainly possible.
SiCrane
SiCrane
You might want to look up JNI.
BlueShizz
BlueShizz
Quote:
Original post by Alpha_ProgDes
Maybe (easily) with VS 2005. Other than that, it sounds like alot of complicated code to glue them together.


It can be done with C++ and J#
BlueShizz
BlueShizz
What compilers are you currently using, BTW?
The C modest god
The C modest god
I have visual 2003 and eclipse.
Should I learn C# then?
That would be the best solution?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
Addictman
Addictman
Like SiCrane said, you can use JNI to execute logic in c/c++.

You can also use a GUI designer like this:
https://abeille.dev.java.net/

which lets you store your GUI layout as an xml file.

If you're doing this out efficiency reasons (game-related),
c# doesn't offer alot of advantages over java.

Development blog, The Omega Sector -- http://www.omegasector.org
The C modest god
The C modest god
Quote:
Original post by Addictman
Like SiCrane said, you can use JNI to execute logic in c/c++.

You can also use a GUI designer like this:
https://abeille.dev.java.net/

which lets you store your GUI layout as an xml file.

If you're doing this out efficiency reasons (game-related),
c# doesn't offer alot of advantages over java.


What I want to prevent is reverse engineering.
So what will be the best solution given this requirement?
C# or java?
Does JNI has performance issues running a CPP compiled code?
It executes source code or compiled code?

It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
dawidjoubert
dawidjoubert
Quote:
Original post by The C modest god
Quote:
Original post by Addictman
Like SiCrane said, you can use JNI to execute logic in c/c++.

You can also use a GUI designer like this:
https://abeille.dev.java.net/

which lets you store your GUI layout as an xml file.

If you're doing this out efficiency reasons (game-related),
c# doesn't offer alot of advantages over java.


What I want to prevent is reverse engineering.
So what will be the best solution given this requirement?
C# or java?
Does JNI has performance issues running a CPP compiled code?
It executes source code or compiled code?


In that case you need to stay away from languages that compile into intermediate code. Visual Basic.NET compiles into an Intermediate Language binary which is why the .net framework is required.. Very easy to reverse engineer
----------------------------http://djoubert.co.uk
SamLowry
SamLowry
Quote:
Original post by The C modest god
Quote:
Original post by Addictman
Like SiCrane said, you can use JNI to execute logic in c/c++.

You can also use a GUI designer like this:
https://abeille.dev.java.net/

which lets you store your GUI layout as an xml file.

If you're doing this out efficiency reasons (game-related),
c# doesn't offer alot of advantages over java.


What I want to prevent is reverse engineering.
So what will be the best solution given this requirement?
C# or java?
Does JNI has performance issues running a CPP compiled code?
It executes source code or compiled code?


C# will indeed not offer any advantages of java, performance-wise. I suggested C# because
* it looks very much like java, you won't have to learn a lot of new stuff
* the IDE, Visual Studio, together with the library offer excellent GUI possibilities + very easy to use
* Making C++ and C# work together is relatively easy using .NET (I would think much easier than java+C++ with JNI, since .NET was created with language-cooperation explicitly in mind)

Regarding reverse engineering: both java and C# compile to intermediate code, but I don't think that is a problem, I'm sure there are tools to make reverse engineering very hard (you can't make it impossible, with any language).
widggman
widggman
You should check some java native function. These functions are writen in C/C++ because they have to deal directly with the OS (like the IO for file and socket...).

This is a list of web site I found on the subject:
* http://www.infini-fr.com/Sciences/Informatique/Langages/Imperatifs/Java/jni.html (IN FRENCH)
* http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html
* http://www.pacifier.com/~mmead/cs510jip/jni/

Or try this one and choose:
http://www.google.ca/search?client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial_s&hl=fr&q=java+native+%22how+to%22&meta=&btnG=Recherche+Google

i don't know if it's really hard to mix Java and C, but it will be more difficult to have a cross-platform application.

Bonne chance!!

deepdene
deepdene
Yeah, .NET comes with a obfuscator tool with the pro edition of Visual Studio from Visual Studio 2003 onwards. It obfuscates the intermediate code to make it harder to reverse engineer.

Quote:
Original post by SamLowry
Quote:
Original post by The C modest god
Quote:
Original post by Addictman
Like SiCrane said, you can use JNI to execute logic in c/c++.

You can also use a GUI designer like this:
https://abeille.dev.java.net/

which lets you store your GUI layout as an xml file.

If you're doing this out efficiency reasons (game-related),
c# doesn't offer alot of advantages over java.


What I want to prevent is reverse engineering.
So what will be the best solution given this requirement?
C# or java?
Does JNI has performance issues running a CPP compiled code?
It executes source code or compiled code?


C# will indeed not offer any advantages of java, performance-wise. I suggested C# because
* it looks very much like java, you won't have to learn a lot of new stuff
* the IDE, Visual Studio, together with the library offer excellent GUI possibilities + very easy to use
* Making C++ and C# work together is relatively easy using .NET (I would think much easier than java+C++ with JNI, since .NET was created with language-cooperation explicitly in mind)

Regarding reverse engineering: both java and C# compile to intermediate code, but I don't think that is a problem, I'm sure there are tools to make reverse engineering very hard (you can't make it impossible, with any language).


The C modest god
The C modest god
I dont understand.
Both java in C# will take my CPP code and compile it into intermediate code?
Also, is it possible with visual .net 2005 to create a GUI like of the sound program aduacity without actually dynamically programing the GUI?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
yaroslavd
yaroslavd
Basically, in .NET it doesn't matter what language you choose - it all compiles down to MSIL (Microsoft Intermediary Language) - basically, .NET bytecode. So you can use C++, C#, J#, whatever your heart desires - the only thing that changes is the syntax (there are some differences between the languages, but don't worry about them for now).

As for the GUI, you basically draw the controls on the screen. It's that easy.
Addictman
Addictman
It simply boils down to personal preference.

All the languages mentioned above can do much of the same, both in terms of GUI and in logic. There is no defined "better language", - if there was, I doubt the others would be as popular as they are.

Like someone already said, you can reverse engineer just about any code in any language. C# and Java are easiar to reverse engineer because they have an extra layer. They are both equally easy to reverse engineer (.net reflector vs. java disassembler), and both languages can be obfuscated to make the code less readable.

As for GUI design. Same here, personal preference. C# and Java offer the same possibilities.

Platform independence. With Mono, not a real issue either. I have not tried Mono myself, but from what I heard, it's good. (So c# and java can both work on multiple platforms).

Performance. Again, not much of a difference. Because I am biased, I think Java is better suited than c# for games. (At least time-sensitive games. Turn-based event-driven games might be just as well written in c#).

IDE's. Visual Studio offers a full package, but imho lacks tidbits that for instance Eclipse has, like "in the moment" error reports, alternative suggestions, automatic insertion of code snippets. Visual Studio offers better gui design support, where in java you'd most likely design gui in another external tool. All in all, pretty even here as well in my opinion.


Combining with other languages. First of all, i never would, if I did not explicitly have to. But if you have to, both java and c# will let you. Combining with managed c++ is easiast in c#. Combining with com is also easiast in c#. Combining with other various languages like prolog, lisp, .. .. is easiar in java.

Basically, it all boils down to: What do you need to do, and what do you want to learn. The alternatives are pretty much open.

Good luck ;)

Development blog, The Omega Sector -- http://www.omegasector.org

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.