Angad
Angad

Reputation: 213

How to call a java class from reactjs app

I have a reactjs app that needs to get data. There is a java class that connects to the database and gets data. Can I call this java class from my react app? I'm a complete newbie with react. Reading and working on my first app.

Thanks!!

Upvotes: 2

Views: 5473

Answers (1)

facundop
facundop

Reputation: 482

Java would be your backend. You need to make a webservice (for instance, a rest service).

Then you would call that service from your React app (your front end).

You can make a rest webservice with pretty much any technology / framework. Something like Spring will get you up and running in 5 minutes: https://spring.io/guides/gs/rest-service/

Complete tutorial using Spring + React: https://spring.io/guides/tutorials/react-and-spring-data-rest/

Upvotes: 4

Related Questions