Javascript is vastly different to Java, try not to get them confused or you will end up with a mass of issues.
You could try basing the exploits off of the code available to you already in the modules directory, but I usually just fire up a http daemon and use the multi-handler in msfconsole - this could be your best bet (and easiest), so long as the payload connects back to metasploit as it should you will retrieve the connection.


