Integration of Java and Python Code in One Eclipse Project

2024/9/23 11:21:31

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.

Answer

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.

https://en.xdnf.cn/q/71831.html

Related Q&A

formatting of timestamp on x-axis

Im trying to format the x-axis in my weather data plot. Im happy with the y-axis but all my tries to get the x-axis into a decent, human-readable format didnt work so far. So after several hours of tri…

How can I set the row height in Tkinter TreeView?

I wrote a small app recently that needs to be cross-platform. I used Python and Tkinter for the GUI.It works great but recently I got a new laptop with a hiDPI screen and it seems to mess up the TreeVi…

Is replace row-wise and will overwrite the value within the dict twice?

Assuming I have following data set lst = [u, v, w, x, y] lst_rev = list(reversed(lst)) dct = dict(zip(lst, lst_rev))df = pd.DataFrame({A:[a, b, a, c, a],B:lst},dtype=category)Now I want to replace the …

Python requests, how to add content-type to multipart/form-data request

I Use python requests to upload a file with PUT method.The remote API Accept any request only if the body contains an attribute Content-Type:i mage/png not as Request Header When i use python requests…

Django Year/Month based posts archive

im new to Django and started an application, i did the models, views, templates, but i want to add some kind of archive to the bottom of the page, something like this http://www.flickr.com/photos/ion…

ValueError: You are trying to load a weight file containing 6 layers into a model with 0

I have a simple keras model. After the model is saved. I am unable to load the model. This is the error I get after instantiating the model and trying to load weights:Using TensorFlow backend. Tracebac…

cProfile with imports

Im currently in the process of learn how to use cProfile and I have a few doubts.Im currently trying to profile the following script:import timedef fast():print("Fast!")def slow():time.sleep(…

Python AWS Lambda 301 redirect

I have a lambda handler written in Python and I wish to perform a 301 redirect to the browser. I have no idea how I can configure the response Location header (or the status code) -- the documentation …

Google Authenticator code does not match server generated code

BackgroundIm currently working on a two-factor authentication system where user are able to authenticate using their smartphone. Before the user can make use of their device they need to verify it firs…

Gekko Non-Linear optimization, object type error in constraint function evaluating if statement

Im trying to solve a non-linear optimization problem. Ive duplicated my issue by creating the code below. Python returns TypeError: object of type int has no len(). How can I include an IF statement in…