Java/Javascript interaction

Hello monkeys, i know this topic is not related to jme but to java in general.

I would like to allow the gamer/user to write small javascript programs which interacts with the game objects. I have googled a bit and found that executing javascript in trough the ScriptEngine would work just fine.

Unfortunately all examples i found covers only function loading and executing them and reading their return value.

My idea would require to call a set of java function from within javascript, for example:





The variable Tank, as well as the functions getWeapon() and the corresponding setters and getters are java objects/functions. (Probably part of an AbstractControl)

Is this possible, and if yes can you please give me a small example, or a link to a corresponding doc?

Thank you in advance


u can use the ScriptEngine from Java6:

You can simply use the java methods / objects from JavaSCript side: