Skip to content

Instantly share code, notes, and snippets.

@teggr
Created May 18, 2016 13:48
Show Gist options
  • Save teggr/ba5a210c7ca3dd936245617a3afdfa08 to your computer and use it in GitHub Desktop.
Save teggr/ba5a210c7ca3dd936245617a3afdfa08 to your computer and use it in GitHub Desktop.
javapoly.js example
<html>
<head>
<!-- Include the Polyfill -->
<script type="text/javascript" src="https://www.javapoly.com/javapoly.js"></script>
<!-- Invoke your Java code from Javascript -->
<script type="text/java">
package com.javapoly.demo;
import com.javapoly.dom.Window;
public class Greeter
{
public static void sayHello(String name)
{
Window.alert("Hello " + name + ", from Java!");
}
}
</script>
</head>
<body>
<!-- Invoke your Java code from Javascript -->
<script type="text/javascript">
JavaPoly.type('com.javapoly.demo.Greeter')
.then(function(greeter){
greeter.sayHello('you dirty dog');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment