JNLP协议开发Java程序

欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入

首先写一个swing的窗口类,然后导出为Hello.jar。 Java代码 public class Hello { public static void main(String[] args) { HelloFrame frame = new HelloFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.show(); } }

class HelloFrame extends JFrame { public HelloFrame() { setTitle(“Hello Swing”); setSize(width, height); } public static final int width = 300; public static final int height = 200; } 在源程序的src目录下运行,使用java自带的签名工具产生签名文件,按照提示一步步完成产生key

keytool -genkey -keystore notepadKeyFile -alias notepadKey

其中,notepadKeyFile是生成的文件名称, notepadKey是别名。可以查阅到相应的证书信息。

用ant来为Hello.jar签名 Xml代码 <?xml version=”1.0″ encoding=”UTF-8″?> <project name=”swing” basedir=”.” default=””>

<property name=”src.dir” value=”${basedir}/src” /> <property name=”dist.lib” value=”${basedir}/dist” />

<!– Directory structure of the project –> <target name=”all” depends=”” description=”generate Key to sign jars”> <signjar alias=”notepadKey” storepass=”hellojava” keypass=”hellojava” keystore=”${src.dir}/notepadKeyFile” verbose=”true”> <fileset dir=”${dist.lib}”> <include name=”*.jar” /> </fileset> </signjar> </target> </project> 建立swing.jnlp文件 Xml代码 <?xml version=”1.0″ encoding=”utf-8″ ?> <jnlp spec=”1.0+” codebase=”http://localhost/easy/” href=”Hello.jnlp”> <information> <title>NotePad V0.1</title> <vendor>wendy</vendor> <description>NotePad V0.1</description> <description kind=”tooltip”> www.ZigzagSoft.net (FreeWare) </description> <offline-allowed /> </information> <security><!–权限设置–> <all-permissions /> </security> <resources> <j2se version=”1.6+” /> <jar href=”Hello.jar” /> </resources>

<application-desc main-class=”net.swi.Hello”><!–主类–> </application-desc> </jnlp>

想起那座山,那个城,那些人……

JNLP协议开发Java程序

相关文章:

你感兴趣的文章:

标签云: