There is a Python 2 implementation called "Jython" - it allows you to execute Python code within the JVM environment, importing and instantiating Java classes normally.
This is what is usually meant by "programming Python and Java together".
Now there is the distributed systems approach - in which independent systems share data and events by media such as web requests, queue managers (redis, Amazon SQS, etc...) to work together. The use of "JSON" would go there: it is a common serialization protocol for data exchange between systems in these cases. Usually these applications that work together are what companies do to accomplish their business - it’s common for a company to have an eco-system with applications in several different languages.
There is much more information and details of these approaches in this response:
It is possible to merge Java with Javascript?
Now, given your clarification:
As java has several features I thought it best to put it as
input manager, and python as it is good for AI I am using for
output. Because I find it difficult to do java AI
It is clear that your premise on the advantages of Java in this case is incorrect. What would be "multiple features"?
You can seamlessly ensure that any "multiple features" for interface, and data input and output, whether on a Web system, terminal, and even a desktop application, are easier in Python (and this can even be demonstrated objectively: the number of language details, classes, interfaces you’ll have to know to create your Python app, relative to Java, will be almost an order of magnitude smaller).
If your interest is to reach an application for Android systems, the obvious choice is to make use of Pyqt5, with pyqtdeploy to create APK. I’m not sure how well the AI libraries themselves will work on Android, and whether pyqtdeploy will be able to package them properly. An alternative is to have the AI part on a remote server, such as backend, and then you create the Android or iOS App on the technology you think best (this is already a distributed system case, as above)
On the other hand, its premise regarding the Python language - that at this point in time, most of the tools and frameworks for AI development have interfaces, examples, and documentation in Python is correct.
The solution for you then is: forget Java for now. If at some point you have an objective reason for using Java (for example, integrating a portion of AI into an existing large system), you come back with this.
And finally, Jython doesn’t have an eco-system where Python’s AI tools are replicated - some probably might work, but will lose efficiency - and it will have little documentation. In addition to what it uses Python 2. The approach to this case would be distributed systems even.
What exactly you need to do in Java and what you need to do in Python?
– Woss
As java has several features I thought it best to put it as input manager, and python as it is good for AI I’m using for output. 'Cause I find it hard to do java AI
– Hytalo Bassi
Your question seems to have some problems and your experience here in Stack Overflow may not be the best because of this. We want you to do well here and get what you want, but for that we need you to do your part. Here are some guidelines that will help you: Stack Overflow Survival Guide in English (short version). If the help is very simple it is still possible to do in the comments.
– Maniero
Python is not good at AI, nothing. Python got a reputation for being good at AI, it’s different. Java can do anything Python can do in AI. Finding difficult is another question. Everything is harder to do in Java. It’s a language that pushes away amateurs, requires a little bit more that the person really learn to program.
– Maniero
It’s just that I’m familiar with AI in python other than java
– Hytalo Bassi
Maniero: "Python is good at AI" - when 90% of AI frameworks make their Apis and documentation available primarily in Python. The premise of Python has always been to facilitate the interface, and let what is computationalemtne intensive run in native code.
– jsbueno
If it’s useful to you, I voted to close because I think a "how I use X and Y together" question is too vague. Depending on the objective, the response will vary or even the recommendation will be "do not use". Addressing all possible contexts in the answer is usually unfeasible and there is a good chance the answer is a "kick" over the context of the question. If the kick is wrong, it will be an invalid answer, which only the questioner can evaluate. That is why I commented questioning what the objectives were and if the question is edited complementing this I will reevaluate my closing vote.
– Woss
I consider it to be a completely valid question, but not in the current format. I disagree with her receiving three negative votes, because she is not all bad; but I also disagree with her receiving three positive votes, because in her current form the question is not enough.
– Woss
For example, an improved form could be "I would like to do ... in Java because ..., but I would like to do ... in Python because ..., how can I integrate these two languages so that this is possible?"
– Woss
@Woss as you may know people vote to be funny, curious, also wanted the opinion, usually biased, of someone on the subject because I want to do the same since I have no ability to make their own decisions. So the question is out of scope, it’s opinion-based, not clear and broad. And in fact the answer given does not answer the question, even if curious, give what people want to hear. In general just thinks good this tip ode question who only answers and does not participate in the community and does not see the lot of problem that this usually generates , even if some case does not generate.
– Maniero
Ok - just help me understand how this answer "doesn’t answer the question"? Her first two lines already answer the question. The rest goes further, including other use cases, including market use, on a large scale. AP approved as answered. What could be more objective than "the Jython project (included link) allows the use of Python and Java in the same program." ?
– jsbueno
"How to program in java and python together?" the question is this and he wants you to help him do something not described. You can’t even answer that, you need at least one chapter of a book. Saying you have a tool that can be used does not answer the question asked. Even more that later the answer says "for your case you can not use what I said that can be used in the beginning". That’s a good comment, not an answer. We have a definition of what is an answer and what is a comment, so a question like that is closed, it is not suitable for an answer, for a comment is.
– Maniero
Accepting an answer is just what I said, the person heard what she wanted to hear, even if it hurts her, even if it leads her down a bad path. That’s why these answers aren’t good. I am not getting into the merits of the specific answer because I am judging the question, and it gives a lot of room for an answer that leads the person down the wrong path, the path that is in someone’s interest. Many times a person accepts because it is what he has, or even to throw a tantrum, happens a lot when someone says the opposite of what he wants to hear.
– Maniero
Responding or accepting something bad happens when the person does not know how the site works. The question is one of the worst ever posted on the site, it’s not a question of being on a thin line. Of course it can be remade and have a purpose, of course, objective, that leads somewhere, and then deserves an answer. This case does not deserve, and the fact that the reply has been posted bypassing the closure does not collaborate. It was a "go in Main".
– Maniero
It is quite simple to understand the problem even. The way it was done can arise numerous answers using Java and Python, all with scenarios, assumptions and purposes completely unrelated to each other.
– Bacco