The link below was the way I got it to work. It has a JS you can get which was made for Java deployment. The link was mentioned above, but I thought an example with it would be nice.
These are samples that I ended up needing to fix my problem.
http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit
Once you have downloaded the deployJava.js file you could put something to make sure java is installed:
if (deployJava.getJREs().length > 0) {
//Your code to start java
}
Make sure a specific version is installed:
if (deployJava.versionCheck(version)) {
//Your version specific code
}
Start the installer of the latest Java:
deployJava.installLatestJava();
Or a specific version if you would like:
deployJava.installJRE(version);