Good mathematically explained algorithm for Hyperparameter Optimization (Bayesian) for implementing in Java

I have implemented Random Forest, Bagging, Gradient Boosting, etc... in java myself. It took a long time to complete these machine learning algorithm codes. But at last all of them are well running. Now I am facing problem in tuning all the hyperparameters corresponding to aforementioned ML algorithms to get the approx. best result. In python or R, there are already some packages (like random search, grid search or Bayesian hyperparameter optimization) which gives best approx. hyperparameters for the corresponding ML algorithm. Now for Gradient Descent or $$k$$-means Clustering or KNN I have already implemented mathematical codes in Java for best choosing $$k$$ and learning rate $$\alpha$$, which will give best approx. result. But for Random forest, Bagging, Gradient Boosting, etc... like algorithms, I want to implement Bayesian hyperparameter optimization in Java. I have go through many books and papers like, enter link description here, enter link description here. But I am not able to understand their algorithms so that I can implement them in Java. These are not much simply I know its may be difficult, but I have already implemented Random Forest and blah blah, so I think I can code this in Java if I get some simple algorithms which will help me to read and think.

If anyone has already implemented this model (Bayesian Optimization for Hyperparameters) in Java or elsewhere thoroughly, please refer me some books or paper from where I can read and can successfully implement in Java, like you.