how could you implement javascript into java

JavaScript
Rhino is what you are looking for.
Source

Also in JavaScript: