Search code examples
javapythoneclipseworkspace

Integration of Java and Python Code in One Eclipse Project


I am writing a compiler in Python using Eclipse with PyDev. I've come to a stage where I needed to write some code in Java. I'm wandering if there is a way of combining these into a single project, because at the moment I have two separate projects, and whenever I need to change the Java code, I have to manually copy the .class file into the Python project.

If this is not possible, what would you suggest is the most elegant way of structuring the files of these projects, and how should I set up my build process?

Thanks.


Solution

  • You can keep things in separate projects without having to copy the .class files to the Python project provided that you make that project a PyDev project and add the place that contains the .class files (i.e.: bin folder) as a source folder in the PyDev configuration (and reference that project from your Python project).

    Take a look at "Project reference for Jython users" (in the end of http://pydev.org/manual_101_project_conf2.html).

    I think you could also do what you asked in your question: create a java project, set it as a PyDev project too (right click that project > pydev > set as pydev project) and configure the PyDev project properties setting the PYTHONPATH to the place where you have your Python files and add another entry to the bin folder (i.e.: where the .class files exist). Not sure if it'd be better to keep those as 2 separated projects though.