2013-04-09 69 views
1

我使用這三個步驟創建了一個java applet,jar文件。我編寫了一個代碼,它可以打開Windows計算器。它使用IDE或從文件夾打開。在瀏覽器獲得權限後不work.What是我的問題Java簽名Applet無法在瀏覽器上工作

3個簡單的步驟:

keytool -genkey -keystore myKeyStore -alias me 

keytool -selfcert -keystore myKeyStore -alias me 

jarsigner -keystore myKeyStore jarfile.jar me 

這是我的代碼

import java.applet.Applet; 

public class Mi extends Applet { 

     /** 
     * @param args the command line arguments 
     */ 
     public static void main(String[] args) { 
     try { 
      Runtime.getRuntime().exec("cmd /c calc"); 
     } catch(Exception exce){ 
      /*handle exception*/ 
      try { 
      Runtime.getRuntime().exec("cmd /c notepad"); 
      } catch(Exception exc){ 
      /*handle exception*/ 

      } 
     } 
     } 
} 

,這是HTML使用

<applet archive="mi.jar" code="Mi"></applet> 
+0

1)'/ *處理異常* /'爲了更好地幫助越早,張貼[SSCCE(http://sscce.org/)。 2)爲什麼使用'Process'而不是'java.awt.Desktop'? 3)這是一個運行流程的非常低劣的實現,如果它工作,我會更驚訝,而不是失敗。 4)你[提示信任](http://stackoverflow.com/q/12986333/418556)新代碼? – 2013-04-10 00:04:14

+0

如果這是您創建的任何通用小程序的問題,那麼您可以試試這個: http://stackoverflow.com/questions/13482331/browser-doesnt-show-java-applet/13487833#13487833 – jatin3893 2013-04-10 18:15:55

回答

1

我之前在帶關鍵字的HTML或類似的下面使用過小程序;

<applet code="mainclass.class" width="500" height="500"> 
my applet 
</applet> 

請你嘗試這些

+0

我試過這些方式它沒有工作 user2102021 2013-04-09 22:21:18

+0

+1 for'width =「500」height =「500」' - 這些是* required attributes *大於100(至少在調試時)。 – 2013-04-10 00:06:49

相關問題