Tuesday, December 28, 2010

Web Services Client

J2SE
http://www.nsftools.com/stubby/ApacheAxisClientTips.htm
http://px.pats.no/px/Eclipse_tutorial.html
http://www.xyzws.com/scdjws/studyguide/jaxrpc_section6.html
http://java.sun.com/developer/technicalArticles/WebServices/WSPack/

J2ME
http://download.oracle.com/docs/cd/B31017_01/web.1013/b28974/j2sewsclient.htm
Introduction to J2ME Web Services (http://developers.sun.com/mobility/apis/articles/wsa/)

Wednesday, December 15, 2010

VMWare克隆或复制Linux虚拟机后无法上网的解决

我拷贝了过来的Linux虚拟机无法上网,我用ifconfig命令查询了一下发现只有eth1和lo设备,没有eth0。于是我在Google上搜索了一下,找到了下面这篇文章(http://blog.chinaunix.net/u3/97076/showart_2015984.html)。
VMWare克隆或复制Linux虚拟机后eth0找不到的解决方案
现象描述:
最近装了虚拟机系统是 fedora9,为了以后使用方便对虚拟机进行克隆或复制。当使用克隆后的虚拟机时发现原来在基本系统中的网卡eth0到了新系统却没有了,使用 ifconfig -a会发现只有eth1。因为基本系统的网络相关配置都是基于eth0的,eth1没有网络相关的配置,此时要正常该虚拟机中的网络,只有添加eth1的 网络配置,这样每次都要修改网卡配置在做多Linux系统测试的时候很不方便。更进一步,如果基于此克隆虚拟机继续克隆或复制新的虚拟机,网卡的标识每一 次都会自动加1(第二次克隆会变成eth2),dmesg却显示内核只识别到网卡eth0。
原因分析:
很多Linux distribution使用udev动态管理设备文件,并根据设备的信息对其进行持久化命名。例如在Debian etch中,udev会在系统引导的过程中识别网卡,将mac地址和网卡名称对应起来记录在udev的规则脚本中。而VMware会自动生成虚拟机的 mac地址。这样,由于基本系统的虚拟机已经记录了该虚拟机的网卡mac地址对应于网卡eth0,在克隆出的虚拟机中由于mac地址发生改变,udev会 自动将该mac对应于网卡eth1。以此类推,udev会记录所有已经识别的mac与网卡名的关系,所以每次克隆网卡名称会自动加1,而其实kernel 仅仅只识别到一张网卡,跟网卡名相关的网络配置也未发生任何变化。
解决方案:
网络搜索发现在Debian etch下,udev将mac与网卡名称的对应关系保存在/etc/udev/rules.d/z25_persistent-net.rules中,在 克隆出的虚拟机中只要删除跟NAME="eth0"相关的行并重启系统即可。例如在Debian etch中删除如下两行:
# PCI device 0x1022:0x2000(pcnet32)SUBSYSTEM=="net",DRIVERS=="?*",ATTRS{address}=="00:0c:29:4c:46:01",NAME="eth0"
在我的fedora9 下修改/etc/udev/rules.d 下的 70-persistent-net.rules 文件 删除
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rule written by anaconda)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:ad:06:2a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
然后把eth1对应的哪一行的"eth1"修改为"eth0"即可。
另外一种方法是:把里面的内容都删除,然后重新启动,系统也会重新发现网卡硬件,重新产生该文件。

这里补充一点:
用下面命令来实现上述第二种方法也是一样的:
cd /etc/udev/rules.d
sudo rm *-net.rules    //删除
sudo reboot
本人在用上述方法操作之后,再用ifconfig查看,确实找到了eth0设备,但没有ip地址。
接下来用ifconfig命令设置ip地址,一些相关命令如下:
ifconfig eth0 192.168.0.10 将采用默认子网掩码
ifconfig eth0 192.168.0.10 netmask 255.255.255.252 (手动定义子网掩码)(重启后无效)
ifconfig eth0 down(停用网卡)
ifconfig eth0 up(激活网卡)
service network restart(重启网络服务)
/etc/rc.d/init.d/network restart(同上)
我用ifconfig eth0 192.168.0.10 netmask 255.255.255.252 设置完ip,然后执行service network restart。
系统提示:eth0已有的MAC地址和系统要设置的不符,设置MAC地址失败。
因为网卡配置信息保存在/etc/sysconfig/network-scripts/ifcfg-eth0配置文件中,所以就去看看它吧。
文件的基本内容如下:
DEVICE=eth0(哪张网卡)
ONBOOT=yes
BOOTPROTO=static(静态ip状态设置)
BOOTPROTO=dhcp(dhcp获取)
IPADDR=192.168.1.8(静态ip地址)
NETMASK=255.255.255.0
GATEWAY=192.168.1.1(网关)
HWADDR=00:0C:29:96:38:F8(修改mac地址)(永久有效)
我把文件的内容进行了删减,只留下
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29:96:38:F8(修改为提示信息中指出的系统期望赋给eth0的MAC)
ONBOOT=yes
重启Linux后可以正常上网了。
另外,VMWare的网络设置中要使用VMnet8,如下图所示:

Sunday, December 12, 2010

BlackBerry Bold: Turn Mass Storage Mode On

Turn on Mass Storage Mode on the BlackBerry Bold smart phone with these steps.
1. Connect the BB to your computer.
2. Press Menu.
3. Select Options.
4. Select Memory.
5. Set Mass Storage Mode Support to On.

Thursday, December 2, 2010

Android programming

  • Tutorial
http://www.vogella.de/articles/Android/article.html
  • How to call web service in web service
http://stackoverflow.com/questions/297586/how-to-call-web-service-with-android
  • Managing State in an Android Activity
http://www.eigo.co.uk/Managing-State-in-an-Android-Activity.aspx
Multiple Activities
http://www.mathcs.org/java/android/multi_acts.html

Windows Mobile Review

Windows Mobile 7
http://en.wikipedia.org/wiki/Windows_Phone_7
Internet Browser Mobile(Pocket Browser)

BlackBerry Debug

How to use jar file as a library (Preverify)
Try with the following approach.
a. Preverify your jar file (just in case if it is not preverified). Follow the steps below for preverifying:

1. Go to your JDE installation folder (C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\bin)

2. Copy the jar file to bin folder.

3. Now open your command prompt and change your current directory to your JDE installation directory.
4. Now execute the following command:
preverify -classpath "C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\lib\net_rim_api.jar" "your_jar_filename"
5. In your bin directory(C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\bin) a folder named output will create.

6. Preverified jar file resides here.
b. Add the preverified jar file to your project (like normal java file).
The above approach worked for me.
If by any chance this approach not work for you. Try with the following:

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800901/How_To_-_Compi...

http://supportforums.blackberry.com/t5/Java-Development/How-to-use-jar-file-as-a-library/td-p/242961

7 Check Log
Alt + LGLG


8. Reboot 
To reboot, simply hit ALTRIGHT SHIFT and DEL.


9. Blackberry app cannot be launched.
There may be multiple main functions in the project.


10. Not use proguard for BB.
I suggest you didn't use Proguard or any obfuscator to obfuscate your code before it goes to rapc, since rapc have it's own obfuscator, i usually use Proguard only for optimization not obfuscating

Wednesday, December 1, 2010

Android debug

1. Java Model Exception: Java Model Status [gen [in MyApp] does not exist]
Try right mouse clicking on Project (in Package Explorer)
Android Tools > Fix Project Properties
Project > Clean......

Delete the R.java file under the gen folder
Refresh the project
Build Project

2. How to check emulator console
adb logcat