Python in java for java servlet

So currently i’m working on a project for which i am using java servlets and stuck on to how to use python in java so i can make predictions using regression plz help me through it…

Hi @saurabh_nale ,

Welcome to the community!

Regarding your question… I don’t think you can use “Python in Java” but you can “call Python FROM Java”. And for that, there are many methods. Just do a quick google on “how to call python from java” and you’ll get a lot of answers.

I hope this helps!

Juan.

1 Like

Thanks for reply, can you suggest one simple method through which i can call functions of python from java this will be very helpful for me.

Unfortunately I don’t have experience on that, so I could not provide a recommendation.

1 Like

One idea that comes to mind:

I have some experience with FastAPI. Basically you can create a REST service with FastAPI, and the FastAPI wraps the Python functions.

Then, from your Java application, you can do REST calls to your Python model via the services exposed by the FastAPI.

1 Like

HI @saurabh_nale

I think these 2 articles will help you
this calling Java from python

this calling python from Java

but my advice is not make your code so complicated …so choice one language and do all project with that and I recommend python as it is an open source language and it has so many libraries and built in models had been implemented with the lowest cost and lowest time in run

please feel free to ask any questions,
Thanks,
Abdelrahman

1 Like

Thanks you are best​:+1::+1:

Thanks for help i appreciate it