2

Is it possible to run Java code in Javascript? Say I had a textbox and when you click the continue it will run the Java function inside the textbox and return results. It doesn't necessarily have to "run" the Java code, if that would be easier. I'm not asking for someone to do all the work for me, but is there any specific way I should go about doing this or are there any libraries that could help me? Also, sorry if my question doesn't make sense or I did something wrong, I'm new here.

Thanks in advance :)

vqdave
  • 2,361
  • 1
  • 18
  • 36
  • 9
    You can embed java applets on the web, otherwise: No. – TheZ Nov 28 '12 at 22:17
  • possible duplicate of [Calling Java inside JavaScript Function](http://stackoverflow.com/questions/6710382/calling-java-inside-javascript-function) – Perception Nov 28 '12 at 22:20
  • 1
    @Sergio no Rhino is a JavaScript interpreter *written* in Java. It may be a good solution if the goal is to do this on the server, though it'd be a little odd for the OP to have made it this far if it were appropriate. – Pointy Nov 28 '12 at 22:21
  • 2
    Also this seems likely to be an [XY Problem](http://www.perlmonks.org/index.pl?node_id=542341). What is it that you're actually trying to achieve? – Pointy Nov 28 '12 at 22:22
  • It is called you want to make an Ajax call back to the server to process the data and than return back the result. – epascarello Nov 28 '12 at 22:27
  • [GWT](https://developers.google.com/web-toolkit/learnmore-sdk) might be what you're looking for. – Louis Wasserman Nov 29 '12 at 02:36

1 Answers1

3

In order for Java code to execute, you need a Java virtual machine. As it turns out, there are a few JavaScript JVM implementations:

josh3736
  • 139,160
  • 33
  • 216
  • 263