There is Rhino from Mozilla: <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/JavaScript_Compiler" rel="nofollow">https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rh...</a>
Why would anyone ever want to do that? Why do you want to do that? There's almost definitely a better way to do whatever you're trying to do.