上一篇我们探究了如何构建Pivot开发框架,编写Pivot桌面应用程序。这一篇我们来说说如何在web环境中部署Pivot程序。webapp发布目录 如下所示:
css中的样式表和js下的JavaScript脚本都是根据官方示例中拷贝下来的,其中最重要的是deployJava.js,它是展示Java applet的工具包,Pivot在页面中就是以Applet的形式展现的,js文件在http://java.com/js/deployJava.js 下载。Lib下是Pivot应用所依赖的类库,可以看出pivot.jar是我自定义的jar,就是编好代码打的包,而WEB-INF/lib下的库和Pivot没有关系,那里的库正常是访问不到的。
下面展示HTML页面
<!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 content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title>Push Buttons</title>
<script src="/pivot/js/deployJava.js" type="text/javascript"></script>
</head>
<body>
<script xmlns="" type="text/javascript">
var attributes = {
code:'org.apache.pivot.wtk.BrowserApplicationContext$HostApplet',
width:'480',
height:'360'
};
var libraries = [];
libraries.push("/pivot/lib/pivot-core-1.4.jar");
libraries.push("/pivot/lib/pivot-wtk-1.4.jar");
libraries.push("/pivot/lib/pivot-wtk-terra-1.4.jar");
libraries.push("/pivot/lib/pivot.jar");
attributes.archive = libraries.join(",");
var parameters = {
codebase_lookup:false,
java_arguments:'-Dsun.awt.noerasebackground=true -Dsun.awt.erasebackgroundonresize=true',
application_class_name:'pivot.tutorials.buttons.PushButtons'
};
deployJava.runApplet(attributes, parameters, "1.6");
</script>
</body>
</html>
关键是JS段代码,其实都是固定套路,只需修改自定义的jar即可,其他段根据字母意思即可理解,关键是lib库的位置一定要对。下面说说ANT打包。
<?xml version="1.0" encoding="UTF-8" ?>
<project name="pivot" default="all">
<description>The Pivot Application</description>
<!-- 定义文件夹 -->
<property name="srcDir" location="." />
<property name="classDir" location="../webapp/WEB-INF/classes" />
<property name="libDir" location="../webapp/WEB-INF/lib" />
<property name="webDir" location="../webapp" />
<!--用于输出打包的文件夹-->
<property name="tempDir" location="${java.io.tmpdir}/${ant.project.name}" />
<property name="targetDir" location="../target" />
<!-- 定义classpath -->
<path id="master-classpath">
<fileset file="${libDir}/*.jar" />
<pathelement path="${classDir}" />
</path>
<!-- 执行清理 -->
<target name="clean">
<delete dir="${classDir}" />
<delete dir="${tempDir}" />
<delete file="${targetDir}/${ant.project.name}.jar" />
<delete file="${targetDir}/${ant.project.name}.war" />
<delete dir="${targetDir}" />
</target>
<!-- 初始化任务 -->
<target name="init" depends="clean">
<mkdir dir="${targetDir}" />
<mkdir dir="${tempDir}" />
<mkdir dir="${classDir}" />
</target>
<!-- 编译 -->
<target name="compile" depends="init" description="compile the source files">
<javac srcdir="${srcDir}" destdir="${classDir}" debug="true" encoding="UTF-8">
<classpath refid="master-classpath" />
</javac>
<copy todir="${classDir}" overwrite="true">
<fileset dir="${srcDir}">
<include name="**/*.xml" />
<include name="**/*.properties" />
</fileset>
</copy>
</target>
<!--打jar包-->
<target name="jar" depends="compile">
<jar jarfile="${targetDir}/${ant.project.name}.jar">
<fileset dir="${classDir}">
<include name="**/*" />
</fileset>
</jar>
</target>
<!—准备war包 -->
<target name="preWar" depends="jar">
<copy todir="${tempDir}/WEB-INF/lib" overwrite="true">
<fileset dir="${libDir}">
<include name="*.jar" />
</fileset>
</copy>
<copy todir="${tempDir}" overwrite="true">
<fileset dir="${webDir}">
<include name="**/*" />
</fileset>
</copy>
</target>
<!--打war包-->
<target name="war" depends="preWar">
<jar jarfile="${targetDir}/${ant.project.name}.war">
<fileset dir="${tempDir}">
<include name="**/*" />
</fileset>
</jar>
</target>
<!-- 清理临时目录 -->
<target name="all" depends="war">
<delete dir="${tempDir}" />
</target>
</project>
Eclipse中已经集成了ANT,只要新建build.xml的文件并且编写,右键就能直接运行,非常方便,ANT构建脚本的编写也很简单,关键是目录迭代不能遗漏,还有目录的定位,不过在IDE中都有提示,也很方便。
将打包好的jar放到webapp/lib下并且修改页面的js段代码即可看到效果了。
欢迎大家交流。
(全篇完)
- 大小: 26.2 KB
- 大小: 66.3 KB
分享到:
相关推荐
Easily set your pivot points inside Unity. Unlike the other pivot editor solutions on the asset store you can set the pivot point using scene handles, snap the pivot to mesh vertices. Features: • ...
PowerPivot 入门手册
搜集的Pivot例子,主要就两个例子以及官方的说明资料。
pivot 130 beta2 full version download
在 Excel 环境中,PowerPivot for Excel 提供熟悉的工作站式的创作和分析体验。在 SharePoint 场中,PowerPivot for SharePoint 添加了服务器端应用程序和功能,支持对您发布PowerPivot指的是一组应用程序和服务,...
高斯迭代解方程 数值分析 西安交通大学 作业
pivot4,最新的pivot,是一款简单易上手的火柴人动画软件,相对以往的pivot3来说,增加了许多新的功能
Pivot3。1 轻松制作火柴人 制作火柴人的首选工具 不得不看 不看后悔
pivot 与 unpivot 函数是SQL05新提供的2个函数 灰常灰常的实用
很多书籍包括教材介绍pivot语句不详细,难以理解其查询结果,这样势必会造成使用该语句时有困难,本文理论讲解透彻,结合例题分析,最后给出实验题目让你练手,以尽快掌握其使用。
asp.net 实现Pivot表,可以实现表的行汇总统计与行列转换。
Pivot unity script using for change pivot in unity editor
pivot火柴人制作工具,可以简单制作火柴人动画flash和图片,对新手来说比flash更方便
PowerPivot for the date analyst:microsoft Excel 2010
matlab 高斯列主元消去法求解线性方程组程序,可用于求解任何元数方程组
pivot d3 的源代码,需要先安装pivot,然后加入d3支持
相反,《微软Excel 2013:用PowerPivot 建立数据模型》承载了大量信息,这样一旦学完《微软Excel 2013:用PowerPivot 建立数据模型》 你在Excel新的建模选项中将有足够的背景知识。用最后一句话来强调这本书的主要...
教你如何创建一个PowerPivot工作簿的教程
旋转标定(Pivot Calibration) 目的: 对每个探针来说, 都有自身的一个参考架(物体坐标系), 但是在导航系统中, 通过反 光球可以识别到的是: 探针的坐标中心位置(3 个自由度, xyz 位置)以及姿态(3 个自 由度, 旋转...
power pivot and power BI