Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is it possible to use Java as a scripting language for a C++ engine/game?

I understand that you need to make a binding to the interpreter, but I haven't seen any around.

share|improve this question
4  
It's more common to use something that is designed to be a scripting language, like Javascript, or Lua, or Python. –  thedaian Jul 29 '11 at 1:30
1  
If you really want to use Java, the best approach would be probably the opposite, call a C++ engine FROM your Java code –  Ioachim Jul 29 '11 at 2:13
    
It is possible but for me the question remains "Why" would you ever use a language with the same complexity for scripting as for the engine? Normally you use a scripting languare that is Much more simple than C++ or Java because you can controle it better and a 'not really a programmer' can make marvels with it! –  Valmond Jul 29 '11 at 17:41
    
@Valmond Why? For Speed! –  LizardGamer Jul 30 '11 at 0:34
    
Then go with C# or even better, C++ ;-) IIRC Lua is quite fast, Python too. –  Valmond Jul 30 '11 at 7:49

6 Answers 6

up vote 7 down vote accepted

Quite possible.

You could probably use the GNU Interpreter for Java or some other such system. However I think you'll find a lot more cases (as mentioned above) of people using Lua, Python or other languages in games. Lua in particular is very well suited for the task of embedded scripting.

Additionally, you might check the jog interpreter project, which touts itself as, "...a lightweight but reasonably full-featured and fast Java compiler and interpreter." that is written in C++.

Amusingly, googling for "java interpreters in C++" seems to yield as many (if not more) hits for C++ interpreters written in Java instead of the other way around :)

share|improve this answer

Yes, it's possible. Way back in 1999, an article was published in Game Developer on the subject, entitled "Dirty Java: Using the JNI Within Games." I still have my copy of issue in fact. Fortunately the article also appears to be available online. Of course, the code in that article is probably a tad out of date, so you can also check out these articles as well:

However, these days it's probably better to consider a language like Python, Lua or Javascript for your embedding needs. They're a lot more lightweight and, in the case of Lua in particular, designed with embedding and scripting in mind.

share|improve this answer

Yes it is possible. Game Vampire the Masquerade - Redemption uses Java as a scripting language. And that game is the only serious game i know of using Java. Bear i mind, they are not using Java for their Nod engine.

Edit: There is JMonkeyEngine written completely in Java.

share|improve this answer
1  
Java was considered as an option for Quake 2 way back in 1997: team5150.com/~andrew/carmack/johnc_plan_1997.html#d19970313 –  Darth Satan Dec 24 '11 at 20:42

Bohemia Interactive (BIS) has announced that Arma3 will use Java as it's scripting language. BIS will be introducing their Java scripting engine in the next patch for Take On Helicopters.

share|improve this answer

MMORPG Darkfall Online uses Java as a scripting engine.

share|improve this answer

Yes it is possible.

However if you are looking for a JVM langauge for scripting, I'd probably recommend either Clojure or Groovy over Java itself - both are dynamic langauges that are better suited for the interactive development style that you usually want with scripting langauges.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.