I don't see this as a Rcpp problem. It works as designed -- your deployment within Java may hamper you.
Reuse of R code is commonly achieved by creating a package which reliably allows you to store and reload object code. That is (among other things) what a package is for.
You essentially ask for a reinvention of sourceCpp()
to also give you the benefits of a package. That won't happen. Please use a package.
And with that this then has nothing to do with the embedding inside a Java app.