title: Generate equivalent Java class from JS with Rhino
body: <p>I have a working Rhino project, with several JavaScript and Java files working together. Now, I would like to compile the JS to Java .class files. It should create the equivalent Java class. One of my JS files would look like this.</p>
  
  <pre><code>load ('org/me/SomeJSClass.js');
  importClass(Packages.org.me.SomeJavaClass);
  
  function Fruit(n, arr) {
      this.name = n;
      this.foo = function(bar) {...};
  }
  </code></pre>
  
  <p>According to <a href="https://stackoverflow.com/a/5057303/2877687">the answer here</a>, I can do that if I first have a Java interface/abstract class to extend from, but I don't want to do that for every JS file. Is there a solution without extending, Java classes. If not, can the Java class be generated for me?</p>