Puzic Elena Also... among those few that attempted to respond beyond the generic "Yes" type answers, you might have noticed there were a range of answers spanning different concepts.
If you were curious why such a varied set of responses, I believe it may be due to the usage of the word "interact," which can imply multiple meanings to different people depending on their level of experiences and exposure to concepts.
I imagine you may also be new to these concepts and therefore may not be aware of the various contexts that could be applied to this question.
To help make this clearer for you and others coming across this question, I'll list a few I saw reflected in the answers:
1. Interoperability via marshalling between processes. This advanced concept can get very complex and involved, but good to eventually learn more about.
2. Integration via HTTP Requests
3. Imported Library References
4. Shared data storage (File/DB)
5. OS Level API Wrappers
6. Microservices via APIs, Service Bus / Message Queue
I found some info on wiki, and take a look what they write:
“Language interoperability is the capability of two different programming languages to natively interact as part of the same system.”
I needed to interpolate Java to C and found information that I need to use jni for it.
Yes they can, and not only using files as Paul Grasser said, you can use them in one single file, for example you can use SQL with Python, or import C++ classes in Python, because I used them, there must be other examples, but this answers your question, yes they can.
At the risk of contributing to the very thing I'm about to criticize, I must comment.
The majority of the responses here remind me of the following dialog:
Q: Do you know what time it is?
The ratio of bad answers (similar to the scenario I just shared) to answers that attempt to provide explanation is alarmingly high.
Puzic Elena It appears you figured out the answer on your own.
It sounds like you were asking about interoperability between multiple application runtimes / processes. This wouldn't necessarily involve multiple languages in the same project. Rather, it's about importing or exposing native interfaces to support a concept known as marshaling. Again, it sounds like you have this figured out already with your reference to JNI. 😉👌
Another example is the Jython framework that allows to use Java classes in Python. Most frameworks like this are language specific.
A more general solution is to create a web server that serves eg. a json. You can use basically any other language to call the server. It's like the frontend-backend example that Gordon mentioned, but with two (or more) backends.