4

How does one go about implementing a scripting engine (I'm thinking Jython) into Java?

I've never done this before, so one major question that I have is; how does the scripting engine know what function calls or fields are available to it?

Is there a simple tutorial to follow on implementing jython into a game? A book possibly?

3
  • 1
    Found my answer at Jython documentation, and the integration is seemless! Very amused by this! Commented May 12, 2011 at 19:54
  • Would you be so kind and help the community (and future googlers) by providing a brief explanation as an answer? Commented May 22, 2011 at 20:15
  • . could you please let us know how can this be done .. Commented Jun 21, 2011 at 7:20

2 Answers 2

1

If you have jython.jar in your path you can start a PythonInterpreter, which can execute and compile strings and files and from which you can get python objects (Strings, Integers, Objects, Functions).

Sign up to request clarification or add additional context in comments.

Comments

0

I created a Java interface and implemented that java interface using python. That way when you get the python class back as a java instance you can type cast it to the interface and know what methods are available. __call__ and __tojava__ are the jython methods to get an instance back from a python implementation.

The Jython Book has a pretty good example and tutorial on how to do this.

http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html#using-jython-within-java-applications

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.