七、本地网页

来源:互联网 发布:暗黑战神 源码分析 编辑:程序博客网 时间:2024/04/28 01:54

若是在网页中嵌入WorldWindJavaApplet,需要发布服务。我用的是Apache+Tomcat整合进行发布该项目,Apache用来访问静态网页,Tomcat则为了使用户访问动态网页。整合步骤见Apache2.4+Tomcat7.0安装整合。

一、导包与数字签名
在网页中访问WorldWindJava三维地球,需要用到jogl包和gluegen-rt包,这两个包在WorldWindJava2.0源码中予以提供。除此之外,还需要WorldWindJava包和我们自己写的WWJMFS包(项目右键导出jar包即可)。
我们如想使用这些包,需要先将其进行数字签名。具体详见Java与数字签名
对这些包签名后,将包拷贝到Apache和Tomcat设置的文件目录中。在此,我的Apache设置的根目录为D:/OceanPlatform,在该文件夹中建立oceanplatform文件夹,我将这些签名后的包拷贝到该文件夹下。(即 http://127.0.0.1/oceanplatform)。

二、jnlp文件的建立
首先先新建WWJMFS.jnlp,代码如下

<?xml version="1.0" encoding="utf-8"?><!--REPLACE EVERYTHING IN ALL CAPS WITH YOUR OWN INFORMATION--><jnlp spec="1.0+"      codebase="http://127.0.0.1/oceanplatform/"      href="WWJMFS.jnlp">    <information>        <title>World Wind Java Application</title>        <vendor>YOUR VENDOR NAME</vendor>        <homepage href="http://127.0.0.1/oceanplatform/"/>        <description>World Wind Java Basic Demo</description>        <description kind="short">World Wind Java Application</description>        <offline-allowed/>    </information>    <security>        <all-permissions/>    </security>     <resources os="Windows">       <property name="sun.java2d.noddraw" value="true"/>     </resources>    <resources>        <j2se href="http://java.sun.com/products/autodl/j2se" version="1.6+" initial-heap-size="512m" max-heap-size="512m"/>        <property name="sun.java2d.noddraw" value="true"/>        <jar href="WWJMFS.jar" main="true"/>        <jar href="WorldWind.jar"/>        <extension name="jogl"                   href="jogl.jnlp"/>    </resources>     <applet-desc        name="WWJApplet"        main-class="esi.oceanPlatform.WWJMFS"        width="800" height="600" style="position:absolute;z-index:0">        <param name="separate_jvm" value="true">     </applet-desc></jnlp>

在该文件中,节点中引用了外部文件jogl.jnlp,代码如下

<?xml version="1.0" encoding="utf-8"?><jnlp codebase="http://127.0.0.1/oceanplatform/"      href="jogl.jnlp">  <information>    <title>Java Binding to the OpenGL API</title>    <vendor>Sun Microsystems, Inc.</vendor>    <homepage href="http://jogl.dev.java.net/"/>    <description>Java Binding to the OpenGL API - JSR-231 Current Build</description>    <description kind="short">Java programming language binding to the OpenGL 3D graphics API. (Current build of JSR-231 APIs)</description>    <offline-allowed/>  </information>  <security>      <all-permissions/>  </security>    <resources>      <jar href="jogl-all.jar" />      <extension name="gluegen-rt" href="gluegen-rt.jnlp" />    </resources>    <resources os="Windows" arch="x86">      <nativelib href = "jogl-all.jar" />    </resources>    <resources os="Windows" arch="amd64">      <nativelib href = "jogl-natives-windows-amd64.jar" />    </resources>    <resources os="Windows" arch="x86_64">      <nativelib href = "jogl-natives-windows-amd64.jar" />    </resources>    <resources os="SunOS" arch="sparc">      <nativelib href = "jogl-natives-solaris-sparc.jar" />    </resources>    <resources os="SunOS" arch="sparcv9">      <nativelib href = "jogl-natives-solaris-sparcv9.jar" />    </resources>    <resources os="SunOS" arch="x86">      <nativelib href = "jogl-natives-solaris-i586.jar" />    </resources>    <resources os="SunOS" arch="amd64">      <nativelib href = "jogl-natives-solaris-amd64.jar" />    </resources>    <resources os="SunOS" arch="x86_64">      <nativelib href = "jogl-natives-solaris-amd64.jar" />    </resources>    <resources os="Linux" arch="i386">      <nativelib href = "jogl-natives-linux-i586.jar" />    </resources>    <resources os="Linux" arch="x86">      <nativelib href = "jogl-natives-linux-i586.jar" />    </resources>    <resources os="Linux" arch="amd64">      <nativelib href = "jogl-natives-linux-amd64.jar" />    </resources>    <resources os="Linux" arch="x86_64">      <nativelib href = "jogl-natives-linux-amd64.jar" />    </resources>    <resources os="Mac OS X" arch="ppc">      <nativelib href = "jogl-natives-macosx-ppc.jar" />    </resources>    <resources os="Mac OS X" arch="i386">      <nativelib href = "jogl-natives-macosx-universal.jar" />    </resources>    <resources os="Mac OS X" arch="x86_64">      <nativelib href = "jogl-natives-macosx-universal.jar" />    </resources>  <component-desc /></jnlp>

同样的,gluegen-rt.jnlp代码

<?xml version="1.0" encoding="utf-8"?><jnlp codebase="http://127.0.0.1/oceanplatform/"      href="gluegen-rt.jnlp">  <information>    <title>GlueGen Runtime</title>    <vendor>Sun Microsystems, Inc.</vendor>    <homepage href="http://gluegen.dev.java.net/"/>    <description>GlueGen Runtime Library</description>    <description kind="short">Run-time support classes and native code for applications and libraries built using the GlueGen tool.</description>    <offline-allowed/>  </information>  <security>      <all-permissions/>  </security>    <resources>      <jar href="gluegen-rt.jar" />    </resources>    <resources os="Windows" arch="x86">      <nativelib href = "gluegen-rt.jar" />    </resources>    <resources os="Windows" arch="amd64">      <nativelib href = "gluegen-rt-natives-windows-amd64.jar" />    </resources>    <resources os="Windows" arch="x86_64">      <nativelib href = "gluegen-rt-natives-windows-amd64.jar" />    </resources>    <resources os="SunOS" arch="sparc">      <nativelib href = "gluegen-rt-natives-solaris-sparc.jar" />    </resources>    <resources os="SunOS" arch="sparcv9">      <nativelib href = "gluegen-rt-natives-solaris-sparcv9.jar" />    </resources>    <resources os="SunOS" arch="x86">      <nativelib href = "gluegen-rt-natives-solaris-i586.jar" />    </resources>    <resources os="SunOS" arch="amd64">      <nativelib href = "gluegen-rt-natives-solaris-amd64.jar" />    </resources>    <resources os="SunOS" arch="x86_64">      <nativelib href = "gluegen-rt-natives-solaris-amd64.jar" />    </resources>    <resources os="Linux" arch="i386">      <nativelib href = "gluegen-rt-natives-linux-i586.jar" />    </resources>    <resources os="Linux" arch="x86">      <nativelib href = "gluegen-rt-natives-linux-i586.jar" />    </resources>    <resources os="Linux" arch="amd64">      <nativelib href = "gluegen-rt-natives-linux-amd64.jar" />    </resources>    <resources os="Linux" arch="x86_64">      <nativelib href = "gluegen-rt-natives-linux-amd64.jar" />    </resources>    <resources os="Mac OS X" arch="ppc">      <nativelib href = "gluegen-rt-natives-macosx-ppc.jar" />    </resources>    <resources os="Mac OS X" arch="i386">      <nativelib href = "gluegen-rt-natives-macosx-universal.jar" />    </resources>    <resources os="Mac OS X" arch="x86_64">      <nativelib href = "gluegen-rt-natives-macosx-universal.jar" />    </resources>  <component-desc /></jnlp>

三、index.jsp文件
在该文件夹中新建index.jsp,并编写代码

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>HelloWorld</title></head><body><div style="position:absolute;z-index:-1;top:0px;bottom:0px;left:0px;right:0px;display:block">    <applet width="100%" height="100%"  id="WWJApplet" style="z-index:-1">    <param name="jnlp_href" value="WWJMFS.jnlp">    </applet></div></body></html>

这样在浏览器中输入 http://127.0.0.1/oceanplatform 即可访问到我们的页面
这里写图片描述

0 0