About neohope

一直在努力,还没想过要放弃...

win7x64+cygwin+vs2010编译64位openjdk6

用VS2010编译OpenJDK6,是一个比OpenJDK7更痛苦的过程。

除了OpenJDK7里需要注意的,还有下面几个:
1、编译器版本不同,所以要自行在Makefile中,增加编译器版本
同样的,还有cp一些dll的命令,需要屏蔽

2、命令冲突
主要是sort和echo

3、Windows版本问题,导致部分define失败,以及部分结构体不存在
从而无法编译通过,主要是

jdk/src/windows/native/sun/windows/awtmsg.h
jdk/src/windows/native/sun/windows/awtMMStub.h
jdk/src/windows/native/java/net/NetworkInterface.h

4、jchar*与LPWCHAR之间的CAST失败,主要存在于

jdk/src/windows/native/sun/windows
jdk/src/windows/native/sun/nio/sun
jdk/src/windows/native/sun/java2d/windows
jdk/src/windows/native/sun/awt/splashscreen

5、设置环境变量的命令行:

@set PATH=C:\Windows\system32;

@call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x64
@set VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools

@set ANT_HOME=D:/JavaTools/apache-ant-1.8.1
@set PATH=%PATH%;%ANT_HOME%\bin;

@set FREETYPE_HOME=D:/GnuWin/freetype2.4.10
@set PATH=%PATH%;%FREETYPE_HOME%/bin;
@set ALT_FREETYPE_LIB_PATH=%FREETYPE_HOME%/lib64
@set ALT_FREETYPE_HEADERS_PATH=%FREETYPE_HOME%/include

@set ALT_BOOTDIR=D:/JavaJDK/jdk1.6.0_34
@set ARCH_DATA_MODEL=64
@set ARCH=amd64
@set PLATFORM=windows
@set ALT_DROPS_DIR=D:/DiskF/OpenJDK/openjdk6_VS2010_x64/drops
@set ALT_COMPILER_PATH=C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/amd64

@set PATH=%PATH%;D:\Cygwin\bin;

@set JAVA_HOME=
@set CLASSPATH=

@color 02
@title OpenJDK6+VS2010+x64

@cmd

Windows2008R2的FTP防火墙配置

最近在Windows2008R2上架设了Windows的FPT服务。

但无论怎样配置防火墙,本地都可以访问,远程只能显示登录框,登录后就卡住不动了。

各种配置入站出站规则。
1、允许了端口
2、允许了服务通过Microsoft FTP Service

还是不行。

最后,增加了一条配置:
允许C:\Windows\System32\svchost.exe通过防火墙,一切正常了。

好吧。。。
虽然这样有风险,但至少管用。

win7x64+cygwin+vs2010编译64位openjdk7

建议:
1、这是一个比较折腾的过程,可能的话建议用linux
2、建议用英文系统
3、建议用英文版的vc++
4、请不要用带空格的路径,尤其是不要用带中文的路径,

主要问题有:
1、可执行文件版本不兼容
2、win和linux路径问题
3、字符集问题,鄙视一下corba的注释,根本没考虑其他字符
4、cl的MT和MD要统一
5、不同路径下文件名冲突问题,

准备与编译:
1、安装VS2010、windows sdk7.1、VS2010 sp1,注意sp1和windows sdk的安装顺序
也有说只有VS的Express版本才需要安装windows sdk的,我反正都安装了。
2、安装directx sdk9(Summer 2004)
3、安装cygwin,并按照要求,下载相应组件,
http://www.cygwin.com/
http://hg.openjdk.java.net/jdk7/jdk7/raw-file/tip/README-builds.html
其中make组件太新,需要替换为3.8.1以前的版本
http://www.cmake.org/files/cygwin/make.exe-cygwin1.7
4、下载JDK6u22+,并安装
5、下载ant,并解压
6、下载并编译FreeType2.4
http://sourceforge.net/projects/freetype/files/
x64+MD+Release
7、下载OpenJDK7,并解压
8、新建drops文件夹,下载下面三个文件,并放到dorps文件夹中:
jaxp145_01.zip
jdk7-jaf-2010_08_19.zip
jdk7-jaxws2_2_4-b03-2011_05_27.zip
理论上,ant应该可以自动下载这三个文件,但我这里下不到
手工下载的话,在Makefile里找下面三个关键字就好了:
jaxp_src.bundle.name
jaxws_src.bundle.name
jaf_src.bundle.name

9、准备编译,新建run.bat,按自己的路径进行修改:

rem 这里是为了解决路径冲突问题
@set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;

rem 注意,这里我的VS和WindowsSDK有冲突,导致VS100COMNTOOLS路径错误
@call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x64
@set VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools

rem ANT配置
@set ANT_HOME=D:/JavaTools/apache-ant-1.8.1
@set PATH=%PATH%;%ANT_HOME%\bin;

rem FreeType配置
@set FREETYPE_HOME=D:/GnuWin/freetype2.4.10
@set PATH=%PATH%;%FREETYPE_HOME%/bin;
@set ALT_FREETYPE_LIB_PATH=%FREETYPE_HOME%/lib64
@set ALT_FREETYPE_HEADERS_PATH=%FREETYPE_HOME%/include

rem Cygwin设置
@set PATH=%PATH%;D:\Cygwin\bin;

rem 这里是OpenJDK的设置啦
@set ALT_BOOTDIR=D:/JavaJDK/jdk1.6.0_34
@set ARCH_DATA_MODEL=64
@set ARCH=amd64
@set PLATFORM=windows
@set ALT_DROPS_DIR=D:/DiskF/OpenJDK/openjdk7_VS2010_x64/drops

rem 这两个变量要置空
@set JAVA_HOME=
@set CLASSPATH=

rem 个人爱好
@color 02
@title OpenJDK+VS2010

@cmd

10、运行run.bat

#测试配置:
make sanity
#没有错误的话:
make

我遇到的问题:
1、主要死到了MT和MD上,这个我修改了Makefile,一定要和FreeType保持一致
2、还有FreeType.dll,我编译的是个大Lib,所以Makefile里拷贝dll的语句要去掉
3、corba的字符集问题,要把Makefile里的ascii去掉,因为生成的注释有中文,显然要出错
4、EXE冲突,我的工具版本很多,估计一般人没这么多问题,最后改了PATH,Find改了名称
比如win的find和cygwin的find,Oracle的zip和cygwin的zip
同样,cygwin和(mingw、GnuSetup、GnuWin)的冲突,也要注意
5、还有一个,就是bat中的路径,除Path外尽量用/,因为linux下,\是转义用的
6、尝试了MinGW,发现不够给力啊

生成xorg.conf文件

1、生成xorg.conf文件

#如果有必要,停止gdm3
service gdm3 stop
#生成空白文件
Xorg -configure
#移动文件
mv ~/xorg.conf.new /etc/X11/xorg.conf
#修改文件,增加需要的分辨率
#如果有必要,开启gdm3
service gdm3 start

2、xorg.conf.new文件

Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
	InputDevice    "Mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
	ModulePath   "/usr/lib/xorg/modules"
	FontPath     "/usr/share/fonts/X11/misc"
	FontPath     "/usr/share/fonts/X11/cyrillic"
	FontPath     "/usr/share/fonts/X11/100dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/75dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/Type1"
	FontPath     "/usr/share/fonts/X11/100dpi"
	FontPath     "/usr/share/fonts/X11/75dpi"
	FontPath     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
	FontPath     "built-ins"
EndSection

Section "Module"
	Load  "record"
	Load  "glx"
	Load  "extmod"
	Load  "dbe"
	Load  "dri"
	Load  "dri2"
EndSection

Section "InputDevice"
	Identifier  "Keyboard0"
	Driver      "kbd"
EndSection

Section "InputDevice"
	Identifier  "Mouse0"
	Driver      "mouse"
	Option	    "Protocol" "auto"
	Option	    "Device" "/dev/input/mice"
	Option	    "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
	Identifier   "Monitor0"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
        ### [arg]: arg optional
	Identifier  "Card0"
	Driver      "vboxvideo"
	VendorName  "InnoTek Systemberatung GmbH"
	BoardName   "VirtualBox Graphics Adapter"
	BusID       "PCI:0:2:0"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	SubSection "Display"
		Viewport   0 0
		Depth     1
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     4
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     8
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     15
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     16
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     24
	EndSubSection
EndSection

3、新版xorg.conf文件

Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
	InputDevice    "Mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
	ModulePath   "/usr/lib/xorg/modules"
	FontPath     "/usr/share/fonts/X11/misc"
	FontPath     "/usr/share/fonts/X11/cyrillic"
	FontPath     "/usr/share/fonts/X11/100dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/75dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/Type1"
	FontPath     "/usr/share/fonts/X11/100dpi"
	FontPath     "/usr/share/fonts/X11/75dpi"
	FontPath     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
	FontPath     "built-ins"
EndSection

Section "Module"
	Load  "record"
	Load  "glx"
	Load  "extmod"
	Load  "dbe"
	Load  "dri"
	Load  "dri2"
EndSection

Section "InputDevice"
	Identifier  "Keyboard0"
	Driver      "kbd"
EndSection

Section "InputDevice"
	Identifier  "Mouse0"
	Driver      "mouse"
	Option	    "Protocol" "auto"
	Option	    "Device" "/dev/input/mice"
	Option	    "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
	Identifier   "Monitor0"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
        ### [arg]: arg optional
	Identifier  "Card0"
	Driver      "vboxvideo"
	VendorName  "InnoTek Systemberatung GmbH"
	BoardName   "VirtualBox Graphics Adapter"
	BusID       "PCI:0:2:0"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	SubSection "Display"
		Viewport   0 0
		Depth     1
		Modes	"1280x800" "1024x768" "800x600"
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     4
		Modes	"1280x800" "1024x768" "800x600"
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     8
		Modes	"1280x800" "1024x768" "800x600"
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     15
		Modes	"1280x800" "1024x768" "800x600"
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     16
		Modes	"1280x800" "1024x768" "800x600"
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     24
		Modes	"1280x800" "1024x768" "800x600"
	EndSubSection
EndSection

Debian6 Squeeze修改Terminal分辨率

试了不少方法,要么参数不支持,要不设置了没有用。

好吧,简单暴力一些。

编辑/boot/grub/grub.cfg,在启动参数前,增加两行:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-amd64' --class debian --class gnu-linux --class gnu --class os {
	#第一行>>>>>>set gfxpayload=1024x768x24
	#第二行>>>>>>load_video
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos1)'
	search --no-floppy --fs-uuid --set a600ccdc-3768-464b-9b19-29ec051f93e5
	echo	'Loading Linux 2.6.32-5-amd64 ...'
	linux	/boot/vmlinuz-2.6.32-5-amd64 root=UUID=a600ccdc-3768-464b-9b19-29ec051f93e5 ro  quiet text
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initrd.img-2.6.32-5-amd64
}
menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os {
	set gfxpayload=1024x768
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos1)'
	search --no-floppy --fs-uuid --set a600ccdc-3768-464b-9b19-29ec051f93e5
	echo	'Loading Linux 2.6.32-5-amd64 ...'
	linux	/boot/vmlinuz-2.6.32-5-amd64 root=UUID=a600ccdc-3768-464b-9b19-29ec051f93e5 ro single 
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initrd.img-2.6.32-5-amd64
}
### END /etc/grub.d/10_linux ###

修改后为:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-amd64' --class debian --class gnu-linux --class gnu --class os {
	set gfxpayload=1024x768x24
	load_video
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos1)'
	search --no-floppy --fs-uuid --set a600ccdc-3768-464b-9b19-29ec051f93e5
	echo	'Loading Linux 2.6.32-5-amd64 ...'
	linux	/boot/vmlinuz-2.6.32-5-amd64 root=UUID=a600ccdc-3768-464b-9b19-29ec051f93e5 ro  quiet text
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initrd.img-2.6.32-5-amd64
}
menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os {
	set gfxpayload=1024x768
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos1)'
	search --no-floppy --fs-uuid --set a600ccdc-3768-464b-9b19-29ec051f93e5
	echo	'Loading Linux 2.6.32-5-amd64 ...'
	linux	/boot/vmlinuz-2.6.32-5-amd64 root=UUID=a600ccdc-3768-464b-9b19-29ec051f93e5 ro single 
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initrd.img-2.6.32-5-amd64
}
### END /etc/grub.d/10_linux ###

VMWare扩展及压缩虚拟磁盘

1、扩展虚拟磁盘
1.1A我的xp虚拟机一共只有10G,我需要扩展到20G(要关虚拟机)

"D:\Program files\VMware\VMware Workstation\vmware-vdiskmanager.exe" -x 20GB "D:\VirtualMashines\VMware\WinXP\WinXP.vmdk"

1.1BVMWare10以后,可以直接在管理工具中
虚拟机-》设置-》硬盘-》实用工具-》扩展

1.2扩展后,开启虚拟机,自己到磁盘管理器中分配空间即可。

2、压缩WinXP虚拟磁盘(vmware-tools)
2.1管理工具(关闭虚拟机)
虚拟机-》设置-》硬盘-》实用工具-》碎片整理

2.2开启虚拟机
系统托盘图标-》vmware-tools-》压缩

3、压缩WinXP虚拟磁盘(vmware-vdiskmanager)
3.1需要到微软官网下载sdelete工具,然后在虚拟机中运行:

sdelete -z

3.2关闭虚拟机,运行:

"D:\Program files\VMware\VMware Workstation\vmware-vdiskmanager.exe" -k "D:\VirtualMashines\VMware\WinXP\WinXP.vmdk"

4、压缩Debian虚拟磁盘:
4.1A在虚拟机中运行zerofree命令,需要将分区挂载为只读模式

apt-get install zerofree
umount /etc/home
zerofree /dev/sda6

4.1B在虚拟机中运行dd命令,需要将分区挂载为读写模式

dd if=/dev/zero of=/bigemptyfile
rm bigemptyfile 

4.2关闭虚拟机,运行:

"D:\Program files\VMware\VMware Workstation\vmware-vdiskmanager.exe" -k "D:\VirtualMashines\VMware\Debian8\Debian8.vmdk"

5、压缩FreeBSD虚拟磁盘:
5.1A在虚拟机中运行dd命令,需要将分区挂载为读写模式

dd if=/dev/zero of=bigemptyfile bs=1m
rm bigemptyfile

5.1B在虚拟机中运行dd命令,需要将分区挂载为读写模式(适用于影片空闲空间较小)

cat /dev/zero > bigemptyfile;sync;sleep 1;sync;
rm -f bigemptyfile

5.2关闭虚拟机,运行:

"D:\Program files\VMware\VMware Workstation\vmware-vdiskmanager.exe" -k "D:\VirtualMashines\VMware\FreeBSD10\Debian8.vmdk"

Axis2 WebService Client

1、Axis2调用WebService一般有两种方法:
a、使用org.apache.axis2.rpc.client.RPCServiceClient自动生成PayLoad
b、使用org.apache.axis2.client.ServiceClient手动生成PayLoad

package com.ats.ws.client;

import javax.xml.namespace.QName;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.log4j.Logger;

import com.ats.db.Person;
import com.ats.db.PersonAddResponse;

public class WSInvoker
{
	private static Logger logger = Logger.getLogger(WSInvoker.class);
	
	private static void invokeWebServiceRPC()
	{
		try
		{
			RPCServiceClient serviceClient = new RPCServiceClient();
			Options options = serviceClient.getOptions();
			options.setTo(new EndpointReference("http://localhost:8080/WebService1/services/PersonManager"));

			// 调用Action
			QName operation = new QName("http://ws.ats.com", "PersonAdd");

			// 调用参数类型和参数值
			Person p = new Person();
			Object req[] = new Object[] { p };
			p.setName("HI");
			Class[] reqClasses = new Class[] { PersonAddResponse.class };

			// 返回结果
			Object[] rsp = serviceClient.invokeBlocking(operation, req, reqClasses);
			PersonAddResponse r = (PersonAddResponse) rsp[0];
			logger.debug(r.getOperationReult());

		} catch (AxisFault e)
		{
			e.printStackTrace();
		}
	}

	public static void invokeWebServiceDocument()
	{
		try
		{
			ServiceClient serviceClient = new ServiceClient();
			Options opts = new Options();
			opts.setTo(new EndpointReference("http://localhost:8080/WebService1/services/PersonManager"));
			opts.setAction("urn:PersonAdd");
			serviceClient.setOptions(opts);

			// 发送请求并并得到返回结果
			OMElement res = serviceClient.sendReceive(createPayLoad());
			logger.debug(res.getFirstElement().getText());
		} catch (AxisFault e)
		{
			e.printStackTrace();
		}
	}

	public static OMElement createPayLoad()
	{
		OMFactory fac = OMAbstractFactory.getOMFactory();
		// 命名空间
		OMNamespace omNsXSD = fac.createOMNamespace("http://ws.ats.com", "xsd");
		OMNamespace omNsXS = fac.createOMNamespace("http://www.w3.org/2001/XMLSchema", "xs");
		// 指定方法
		OMElement method = fac.createOMElement("PersonAdd", omNsXSD);
		// 指定方法的参数
		OMElement p1 = fac.createOMElement("person", omNsXS);
		
		OMElement personName = fac.createOMElement("personName", omNsXS);
		personName.setText("personName");
		p1.addChild(personName);
		OMElement personid=fac.createOMElement("personid", omNsXS);
		personid.setText("");
		p1.addChild(personid);
		
		method.addChild(p1);
		return method;
	}

	public static void main(String[] args)
	{
		WSInvoker.invokeWebServiceRPC();
		WSInvoker.invokeWebServiceDocument();
	}
}

2、要想看到网络通讯的话,在log4j的配置文件中增加:

	<category name="org.apache.commons.httpclient">
		<priority value="WARN" />
	</category>
	<category name="httpclient.wire">
		<priority value="DEBUG" />
	</category>