zhangv on August 9th, 2008

(翻出来的一篇老文,备份上来)
14:09 2006-7-14
一.从eclipse输出项目jar包  — 注意main-class的设置
二.将所有依赖包签名
a.怎么创建签名:
1.创建密钥库
keytool -genkey -keystore myKeystore -alias myself
myKeystore 密钥库的名字(这里会生成一个以它为文件名的文件,该文件不能移动位置)
myself 密钥的别名
2.根据创建好的密钥库创建自己的证书
keytool -selfcert -alias myself -keystore myKeystore
3.查看密钥库中是否创建了相应的证书
keytool -list -keystore myKeystore
Keystore 类型: jks
Keystore 提供者: SUN
您的 keystore 包含 1 输入
myself, 2006-7-13, keyEntry,
认证指纹 (MD5): A7:BB:42:89:15:B4:4E:7A:2E:A4:4F:E5:89:24:06:55
b.怎样给jar文件签名
jarsigner -keystore myKeystore test.jar myself
myKeystore 指定密钥库
myself 指定要使用的密钥的别名
test.jar 要签名的jar文件
(所有要发布的jar包都要签名)
三.创建jnlp文件(jws的部署描述文件)
jnlp文件中使用的标签参考:http://java.sun.com/j2se/1.4.2/docs/guide/jws/developersguide/syntax.html
例子:
<?xml version=”1.0″ encoding=”utf-8″?>
<jnlp spec=”1.0+” codebase=”http://localhost:8080/” href=”rssreader.jnlp”>
<information>
<title>**title**</title>
<vendor>**vendor**</vendor>
<description>**description**</description>
<description kind=”short”>**anther description**</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se      version=”1.4+”/>
<jar       href=”rssreader.jar”/>
</resources>
<resources os=”Windows”>
<jar       href=”jdic.jar”/>
<jar       href=”lib/commons-collections-3.1.jar”/>
<jar       href=”lib/commons-configuration-1.2.jar”/>
<nativelib href=”jdic-native.jar”/>
</resources>
<application-desc main-class=”com.zhangv.rss.RssReader”/>
</jnlp>
四:发布
将所有文件(jnlp,jar)放到服务器上,注意相对路径
五:使用jdic的程序发布还是有问题
难道客户端一定还要配置那些(dll,exe)到path吗?
nativelib为什么没有起作用?

Continue reading about 如何创建一个可执行的jar并使用jws发布

zhangv on July 5th, 2008

很早前在学校时候写的一个生成目录文件列表的东西,因为那时候自己开了一个ftp服务器。
import java.util.Date;
import java.util.Arrays;
import java.io.*;
/**
* Time: 2003-12-23 20:46:42
*/
public class FileManager {
private String ListFilename = “@list.txt”;
private String root;
private String updatetime;
public FileManager(String root) {
this.root = root;
updatetime=new Date().toString();
}
private void getList(String dir) {
File tmp = new File(dir);
File[] files = tmp.listFiles(new ffilter());
File[] dirs = tmp.listFiles(new dfilter());
if (files.length != 0) {
writeListFile(files);
}
if (dirs.length != 0) {
for (int i = 0; i < dirs.length; […]

Continue reading about 递归生成目录文件列表

zhangv on June 13th, 2008

推荐swing上的calendar组件 - toedter

推荐swt上的calendar组件 - swtcalendar

Continue reading about Swing和SWT的Calendar组件

zhangv on June 7th, 2008

放到这里留作备份.还有一个pdf版的更详细.

Continue reading about SimpleFormController的流程图

当用sun的odbc-jdbc driver去连接access时会出现这个问题(用ibatis)
因为这个driver不支持long类型的字段,解决办法:
在类中把相应字段类型改为bigdecimal或者int。

Continue reading about [ODBC Microsoft Access Driver]Optional feature not implemented

今天用httpunit写一个测试时候发现无法设置select框,报错是:
com.meterware.httpunit.IllegalParameterValueException: May not set parameter ‘userInfo.processingUnit’ to ‘BOM’. Value must be one of: { }
at com.meterware.httpunit.SelectionFormControl$Options.reportNoMatches(FormControl.java:1186)
at com.meterware.httpunit.SelectionFormControl$SingleSelectOptions.claimUniqueValues(FormControl.java:1360)
at com.meterware.httpunit.SelectionFormControl$Options.claimUniqueValues(FormControl.java:1178)
at com.meterware.httpunit.SelectionFormControl.claimUniqueValue(FormControl.java:1059)

跟进发现,webform无法通过getOptions来获取选择项.google后发现有人建议把页面中的
<html xmlns=”http://www.w3.org/1999/xhtml”>
改成
<html>
果然管用. 为什么会影响到httpunit? 指定上述的命名空间的意思是说这个html文档是遵守xhtml规范.通过下面的方法打开httpunit的解析详情 - httpunit会在得到html内容后告诉你这个文档是否遵守了你所指定的规范.(这里是xhtml).
HttpUnitOptions.setParserWarningsEnabled(true);
结果会得到这样的信息:
At line 121, column 1: Element <BODY> not closed properly.
At line 121, column 1: Element <HTML> not closed properly.
At line 1249, column 1: Element <BODY> not closed properly.
At line 1249, column […]

Continue reading about httpUnit无法获取select框的选项值(options)

zhangv on March 11th, 2008

Javablog » How MIDlet Signing is Killing J2ME
TODO: 翻译

Continue reading about Javablog » How MIDlet Signing is Killing J2ME

zhangv on February 20th, 2008

偶然的灵感, 能否以后编程就和写作文一样呢? 这也应该是面向对象的终极目标吧.下面这个是经常出现在教科书上的例子.
Person tom = new Person() - > tom is a Person
Dog trigger = new Dog() -> trigger is a Dog
List<Person> friends = new ArrayList<Person> - > Person have Person friends
Person implements Emotianal,HumanBehave -> Person behave Emotional and surely behave as a human.
interface Emotional{ sadly(); happily();} ->Emotional including sadly and happily doing things.
interface […]

Continue reading about 软件建模三元素

zhangv on January 3rd, 2008

XUL - xml user interface language, mozilla推出的,firefox就是基于此. flex,zk都是这个意思
http://www.mozilla.org/projects/xul/
Thinlet - 开源XUL引擎,通过XUL分离业务逻辑和界面,基于AWT
ThinG - 用来编写thinklet的XUL的工具,thing.sourceforge.net.通过ThinG配合thinlet使用可以很快速方便的开发awt界面.Theodore - 同上,但是是收费的
genesis - 开发框架,用于企业应用开发的,但是没有体会到有多好,测试sample里的thinlet时AspectWerkz出错,保持关注
swiXML - 类似thinlet但是是用于swing的
jdnc - Sun力推的XUL解决方案,没看出有什么动向,保持关注

Continue reading about Thinlet 二三事

zhangv on January 2nd, 2008

-Dcom.sun.management.jmxremote.port=44444
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
sample:
java YourMainClass -Dcom.sun.management.jmxremote.port=44444 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
然后在远程jvm上使用 命令jconsole打开 控制台, 输入目标jvm的ip和上面指定的端口(44444). 就可以看到jvm的详细数据了:线程,堆空间,内存使用,cpu使用,mbean…

Continue reading about 配置jvm远程管理控制台