Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a Java project which uses Java to access some 3rd party libraries. For other things I'd like to use something newer like Python maybe. Is it easy to incorporate into an existing project? How do people usually do that?

Thanks, Alex

share|improve this question

closed as not constructive by Yannis Rizos Mar 25 '12 at 0:31

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

Other than "newer," what benefit do you get from Python? –  Anon Apr 19 '11 at 20:57
Actually, Python (appeared in 1991) is older than Java (appeared in 1995). –  Mahmoud Hossam Jun 13 '11 at 22:12
This question was closed during the STCI [software-engineering] cleanup. –  Yannis Rizos Mar 25 '12 at 0:31

1 Answer 1

It's quite easy to integrate Python with Java. You can start with Jython : http://wiki.python.org/jython/WhyJython

This is the way Oracle implemented WLST for they Weblogic server so it's quite a stable technology.

As described in the FAQ :

Is Jython the same language as Python?

Yes. Jython is an implementation of the Python language for the Java platform. Jython 2.5 implements the same language as CPython 2.5, and nearly all of the Core Python standard library modules. (CPython is the C implementation of the Python language.) Jython 2.5 uses the same regression test suite as CPython, with some minor modifications.

There are a number of differences. First, Jython programs cannot currently use CPython extension modules written in C. These modules usually have files with the extension .so, .pyd or .dll. If you want to use such a module, you should look for an equivalent written in pure Python or Java. However, it is technically feasible to support such extensions, as demonstrated by IronPython. For the next release of Jython, we plan to support the C Python Extension API.

There are a number of other differences between the two implementations that are unlikely to go away. These range from the trivial - Jython's code objects currently do not have a co_code attribute because it is not possible to directly access Java bytecode from a class, without loading the file; to the significant - Jython uses Java's true garbage collection rather than Python's reference counting scheme.

share|improve this answer
@Micel But if I use Jython, it is no longer the real Python, right? It is a separate tool with a JVM that tries to be like Python? Do I understand it correctly? –  Genadinik Apr 20 '11 at 16:20
@Genadinik it's the same language, see edit above –  Michel Daviot Jun 13 '11 at 19:08

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