在一个Eclipse项目中集成Java和Python代码 [英] Integration of Java and Python Code in One Eclipse Project

查看:244
本文介绍了在一个Eclipse项目中集成Java和Python代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse和PyDev在Python中编写一个编译器。我来到了一个需要用Java编写代码的阶段。如果有一种方法可以将这些组合到一个项目中,我就会徘徊,因为目前我有两个独立的项目,每当我需要更改Java代码时,我必须手动将.class文件复制到Python项目中。



如果这是不可能的,你会建议什么是构建这些项目文件的最优雅方式,我应该如何设置我的构建过程? / p>

谢谢。

解决方案

你可以将东西保存在单独的项目中将.class文件复制到Python项目,前提是您将该项目作为PyDev项目并将包含.class文件的位置(即:bin文件夹)添加为PyDev配置中的源文件夹(并从您的项目中引用该项目) Python项目)。



看看Jython用户的项目参考(在 http://pydev.org/manual_101 _project_conf2.html )。



我想你也可以做你在问题中提出的问题:创建一个java项目,也将它设置为PyDev项目(右键单击该项目> pydev>设置为pydev项目)并配置PyDev项目属性,将PYTHONPATH设置为您拥有Python文件的位置,并将另一个条目添加到 bin 文件夹(即:.class文件存在的位置)。不确定是否最好将这些作为2个独立的项目保留。


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.

解决方案

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.

这篇关于在一个Eclipse项目中集成Java和Python代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆