2013-04-09 70 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

相关问题