java和python可以在一个项目中同时使用么-在一个Eclipse项目中集成Java和Python代码...

1586010002-jmsa.png

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值