Also, if you already have a Java installation with matching architecture (i.e. x64 or x86) but R still can't recognize it, you can try manually setting the location by adding a line like this to your Rprofile.site file (you have to change the file path accordingly to your own Java installation).
Sys.setenv('JAVA_HOME'="C:/Program Files/Java/jdk-11.0.1/")