Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
del *.cer
del *.com
del *.jar
del *.class
javac -classpath ".;C:\Program Files\Java\j2re1.4.2_04\lib\plugin.jar" test.java
keytool -genkey -keystore harm.com -keyalg rsa -dname "CN=Harm Meijer, OU=Technology, O=org, L=Amsterdam, ST=, C=NL" -alias harm -validity 3600 -keypass pass -storepass pass
jar cf0 test.jar test.class
jarsigner -keystore harm.com -storepass pass -keypass pass -signedjar sTest.jar test.jar harm
del *.class
<DIV id="dvObjectHolder"> </DIV>
<br><br>
<script>
if(window.navigator.appName.toLowerCase().indexOf("netscape")!=-1){ // set object for Netscape:
document.getElementById('dvObjectHolder').innerHTML = " <object ID='appletTest1' classid=\"java:test.class\"" +
"height=\"0\" width=\"0\" onError=\"changeObject();\"" +
">" +
"<param name=\"mayscript\" value=\"Y\">" +
"<param name=\"archive\" value=\"sTest.jar\">" +
"</object>";
}else if(window.navigator.appName.toLowerCase().indexOf('internet explorer')!=-1){ //set object for IE
document.getElementById('dvObjectHolder').innerHTML = "<object ID='appletTest1' classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\"" +
" height=\"0\" width=\"0\" >" +
" <param name=\"code\" value=\"test.class\" />" +
"<param name=\"archive\" value=\"sTest.jar\">" +
" </object>"
}
</script>
<LABEL id="lblOutputText">This text will be replaced by the applet</LABEL>
<BR>
<input value="Javascript to java" type=button onClick="document.appletTest1.fromJavaScript()"><br>
// new class for jsObject!!!! since 1.4.2 compile this:
// javac -classpath "C:\Program Files\Java\j2re1.4.2_01\lib\plugin.jar" test.java
// since jaws.jar does not exsist anymore
// to compile with jaws: javac -classpath "C:\j2sdk1.4.0_03\jre\lib\jaws.jar" test.java
import netscape.javascript.*;
public class test extends java.applet.Applet {
JSObject win;
JSObject outputLabel;
public void init() {
try{
win = JSObject.getWindow(this);
outputLabel = (JSObject) win.eval("document.getElementById('lblOutputText')");
outputLabel.setMember("innerHTML", "<center><h1>From Init<br>Your homedir " + System.getProperty("user.home") + "</h1></center>");
}catch(Exception e){
e.printStackTrace();
}
}
public void fromJavaScript(){
try{
outputLabel.setMember("innerHTML", "<center><h1>From javascript<br>Your homedir: "+ System.getProperty("user.home") + "</h1></center>");
}catch(Exception e){
e.printStackTrace();
}
}
}
java.security.AccessControlException: access denied (java.util.PropertyPermission user.home read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at test.fromJavaScript(test.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
at sun.plugin.com.DispatchImpl$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
// new class for jsObject!!!! since 1.4.2 compile this:
// javac -classpath "C:\Program Files\Java\j2re1.4.2_01\lib\plugin.jar" test.java
// since jaws.jar does not exsist anymore
// to compile with jaws: javac -classpath "C:\j2sdk1.4.0_03\jre\lib\jaws.jar" test.java
import netscape.javascript.*;
public class test extends java.applet.Applet {
JSObject win;
JSObject outputLabel;
boolean buttonFromJavaClicked = false;
checkJavaScriptEvent evt = new checkJavaScriptEvent();
public void init() {
try {
evt.start();
win = JSObject.getWindow(this);
outputLabel =
(JSObject) win.eval("document.getElementById('lblOutputText')");
outputLabel.setMember(
"innerHTML",
"<center><h1>From Init<br>Your homedir "
+ System.getProperty("user.home")
+ "</h1></center>");
} catch (Exception e) {
e.printStackTrace();
}
}
public void fromJavaScript() {
buttonFromJavaClicked = true;
}
private void fromJavaScript2() {
System.out.println("fromjavascript2 is started");
try {
String strLbl =
"<center><h1>From javascript<br>Your homedir: "
+ System.getProperty("user.home")
+ "</h1></center>";
outputLabel.setMember("innerHTML", strLbl);
} catch (Exception e) {
e.printStackTrace();
}
}
class checkJavaScriptEvent extends Thread {
public void run() {
while (true) {
if (test.this.buttonFromJavaClicked) {
System.out.println("OK buttonfromjava is true");
test.this.buttonFromJavaClicked = false;
test.this.fromJavaScript2();
}
try {
Thread.sleep(300);
} catch (Exception e) {
System.out.println("exception in sleep");
e.printStackTrace();
System.exit(1);
}
}
}
}
}