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

Tuesday, November 30, 2010

Error :UI engine accessed without holding the event lock.

http://rob.wemakewebsites.co.nz/index.php?p=39

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/How_to_-_Manage_UI_interactions.html?nodeid=800514&vernum=0

Thursday, November 25, 2010

VS编译动态库无法直接运行,所需的其他文件说明(Visual C++ Libraries as Shared Side-by-Side Assemblies)

Refer to
http://www.cppblog.com/noswimfish/archive/2010/11/24/123742.html

The ATL, MFC, Standard C++, and CRT libraries support the deployment model available on Windows XP, Windows Server 2003, and Windows Vista. The DLLs corresponding to all Visual C++ libraries have been grouped into several shared side-by-side assemblies and are installed into the native assembly cache, also called the WinSxS folder, under the operating system root directory. Similarly, while building a C++ application by using Visual C++, by default the compiler and the linker generate a manifest file that describes runtime dependencies of this application on Visual C++ libraries.

Visual C++ libraries cannot be used by a C/C++ application without a manifest binding the application to these libraries. If a C/C++ application that depends on a Visual C++ library does not use a manifest, then an attempt to load the Visual C++ library as a dependent DLL from the application-local folder will result in an error message indicating that this is an unsupported way of loading a Visual C++ library.
NoteNote

On versions of Windows that do not support deployment of shared side-by-side assemblies, such as Windows 98 and Windows 2000 Server, the Visual C++ libraries are installed in the System32 folder and WinSxS folder under the operating system root directory. This setup enables running Visual C++ applications on these operating system versions because they do not support manifest-based binding of applications to dependent DLLs. On these operating systems, when an application is loaded, the corresponding manifest file is ignored and the operating systems searches for dependent DLLs using paths set in the current running environment. However, on upgrading the operating system to a version that support manifest-based binding, such as Windows XP, Windows Server 2003, or Windows Vista, applications built with manifests start using the DLLs installed in the WinSxS folder.

This change to the deployment model of Visual C++ libraries prevents the problem of version conflicts between DLLs that occur when you add updates or configurations to a machine, and will allow support of side-by-side installation of two different Visual C++ toolsets. It will also allow you to produce reliable, self-describing applications and components that will not conflict with existing components. For more information on the advantages of new deployment model, please see Concepts of Isolated Applications and Side-by-side Assemblies. To learn about how this may impact deployment of existing native C++ applications, please refer to Redistributing Visual C++ Files.

Visual C++ libraries have been packaged in several shared side-by-side assemblies with corresponding manifest files.

Assembly Name


DLLs included in the assembly


Visual C++ Library

Microsoft.VC90.ATL


atl100.dll


Active Template Library

Microsoft.VC90.CRT


msvcr100.dll

msvcp100.dll

msvcm100.dll


C Runtime Library, release DLLs

Microsoft.VC90.DebugCRT


msvcr100d.dll

msvcp100d.dll

msvcm100d.dll


C Runtime Library, debug DLLs

Microsoft.VC90.MFC


mfc100.dll

mfcm100.dll

mfc100u.dll

mfcm100u.dll


Microsoft Foundation Classes, release DLLs

Microsoft.VC90.DebugMFC


mfc100d.dll

mfcm100d.dll

mfc100ud.dll

mfcm100ud.dll


Microsoft Foundation Classes, debug DLLs

Microsoft.VC90.MFCLOC


mfc100chs.dll

mfc100deu.dll

mfc100esn.dll

mfc100ita.dll

mfc100kor.dll

mfc100cht.dll

mfc100enu.dll

mfc100fra.dll

mfc100jpn.dll

mfc100rus.dll


Microsoft Foundation Classes, localized resources

Microsoft.VC90.OpenMP


vcomp100.dll


OpenMP Library, release DLLs

Microsoft.VC90.DebugOpenMP


vcomp100d.dll


OpenMP Library, debug DLLs

When you build applications with Visual C++ 2008, you may need to redistribute Visual C++ libraries and deploy the corresponding DLLs to customers' desktops. For more information please see Deployment (C++).
Feedback
# re: VS编译动态库无法直接运行,所需的其他文件说明(Visual C++ Libraries as Shared Side-by-Side Assemblies) 回复 更多评论
2010-11-24 09:32 by 杨书童
在VS2005下用C++写的程序,在一台未安装VS2005的系统上,
用命令行方式运行,提示:
“系统无法执行指定的程序”
直接双击运行,提示:
“由于应用程序的配置不正确,应用程序未能启动,重新安装应用程序可能会纠正这个问题”

以前用VC6和VS2003的话, 如果缺少库文件,是会提示缺少“**.dll”,但是用VS2005却没有这样的提示。

自己实验了一下,感觉以下几种解决办法是可行的:
方法一:
在类似C:\Program Files\Microsoft Visual Studio 8\VC\redi
st\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT 下找到了下列文件:

msvcm80d.dll
msvcp80d.dll
msvcr80d.dll
Microsoft.VC80.DebugCRT.manifest

把这几个文件拷贝到目标机器上,与运行程序同一文件夹或放到system32下,就可以正确运行了。

其他release版、MFC程序什么的都是拷redist下相应文件夹下的文件就可以了,文件夹后都有标识!

方法二:
修改编译选项,将/MD或/MDd 改为 /MT或/MTd,这样就实现了对VC运行时库的静态链接,在运行时就不再需要VC的dll了。

方法三:

工程-》属性-》配置属性-》常规-》MFC的使用,选择“在静态库中使用mfc”
这样生成的exe文件应该就可以在其他机器上跑了。

方法四:

你的vc8安装盘上找到再分发包vcredist_xxx.exe和你的程序捆绑安装
刷新评论列表

http://msdn.microsoft.com/en-us/library/aa260978%28VS.60%29.aspx

Monday, November 22, 2010

Porting x86 programs to x86_64

Refer to:
http://www.physics.uq.edu.au/people/foster/amd64_porting.html


Porting x86 programs to x86_64

Since buying my amd64 system in 2004 I have been running a 64-bit linux kernel, and often want to run programs which have been developed for 32-bit x86 processors. Porting code to amd64 from x86 is usually a fairly straightforward task involving fixing a few type problems. The following describes some of the issues I've encountered when porting to x86_64 in the hope that it will save someone some time.
Sizes of integer and pointer types

One of the most common problems encountered in programs written for x86 is assumptions about the size of pointer and integer types. Typically this leads to truncation; a common C++ error looks like the following:

string str = get_some_string();
unsigned int delimPos = str.find(':');
if(delimPos != string::npos)
handle_delimiter(str);

However, since an unsigned int encompasses a smaller range than string::size_type, string::npos is truncated to fit, and the conditional is always executed.

Actually, using the unsigned int above is just bad practise and should be avoided in favour of the proper type provided by the standard library, string::size_type. These kinds of errors easily slip by on a 32-bit system however where we typically have unsigned int == string::size_type. Luckily they're easily found by a compiler - study your compiler warnings carefully - they are usually there for a reason!
Pointers

A bunch of nastier errors occur because the pointer size on a 64-bit system is naturally enough 64 bits wide. Any code which is doing horrible low-level things involving casting pointers to integers will probably break in a rather nasty fashion.
Sizes of types, for the record

The trivial piece of C++ code here shows the relevant sizes of various types. For a 64-bit amd64 system using g++, I have the following:

$ ./test_data_sizes
Integer types:
sizeof(char) = 1
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 8
sizeof(long long) = 8

Pointers:
sizeof(void*) = 8

Floating point types:
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double) = 16

Sizes from stddef.h:
sizeof(size_t) = 8
sizeof(ptrdiff_t) = 8

On the other hand, when compiled with g++ on a 32-bit system (i686) we get the following:

$ ./test_data_sizes
Integer types:
sizeof(char) = 1
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 4
sizeof(long long) = 8

Pointers:
sizeof(void*) = 4

Floating point types:
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double) = 12

Sizes from stddef.h:
sizeof(size_t) = 4
sizeof(ptrdiff_t) = 4

Of particular relevance, the sizes of the long, void* and types from stddef.h are different. Note that these results also may depend on the compiler, not just the architecture. I've been told that VC++ differs from g++ with regard to the sizeof(long).
Position Independent Code and Non-x86 Architectures; -fPIC

Another problem which often rears its ugly head is related to the difference between the way that the two platforms handle position independent code (PIC) and indicates that the build system rather than the source code needs to be modified. Since there's been a distinct lack of information on the web about this, here's my take on the subject. I'm not an expert, so take it with a grain of salt; constructive feedback is always welcome.

Briefly, position independent code is object code which may be put at an arbitrary position in memory and executed without modification. This is in contrast to (relocatable) position dependent code which needs an extra translation step. One upshot is that PIC is appropriate for use in shared objects.

In order to generate PIC with gcc, the option -fPIC should be used. Portability issues arise when a build system assumes that position dependent code can be linked into a shared library. Because of architectural peculiarities this assumption is fine on a x86 system, but invalid on many others, including amd64.
An Example

Suppose I decide to write a library containing a single function, writeHello(), the source files being as follows:

// hello.h
#ifndef HELLO_H
#define HELLO_H

void writeHello();

#endif // HELLO_H

// hello.cpp
#include
#include "hello.h"

void writeHello()
{
std::cout << "Hello World!\n";
}

If we attempt to compile these into a shared library without using -fPIC, we get the following mess:

$ g++ -c -o hello.o hello.cpp
$ g++ -shared -o libhello.so hello.o
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/../../../../x86_64-pc-linux-gnu/bin/ld:
hello.o: relocation R_X86_64_32 against `a local symbol' can not be used when
making a shared object; recompile with -fPIC
hello.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
$

On the other hand, if we include an -fPIC in the compile options, everything is fine, and out pops a shiny new shared object:

$ g++ -c -fPIC -o hello.o hello.cpp
$ g++ -shared -o libhello.so hello.o

Granted it doesn't do much... but not to worry ;)
Shared and static libraries

The example above is a very simple case of where you can get into trouble with non-PIC object code. A more complicated case involves attempting to link static libraries into shared libraries. Suppose I created a bunch of static libraries, libfoo.a, libbar.a and libbaz.a and I wanted to link them into a shared object libfred.so. On x86 it is permissible to create the static libraries out of non-PIC objects. However, the following will fail on the amd64 architecture unless the static libraries are built with -fPIC:

$ g++ -shared -o libfred.so $fred_objects -lfoo -lbar -lbaz

Relevance to automated build tools
Autoconf et. al.

The nasty mess that is the GNU autotools has a uniform way for dealing with generating position independent code - the relevant command line flag, --with-pic will cause static libraries to be built as PIC, and avoids the library issue mentioned above. The autobook briefly mentions this though I haven't played with it myself so I'm not sure if the option is relevant if libtool is not being used.
SCons

SCons automatically determines whether to use -fPIC when creating libraries using the StaticLibrary or SharedLibrary builder methods. However, you've still got to be careful with linking static libraries made from non-PIC objects into shared libraries. This page resulted from my search for a clean solution to this problem for use with the Aqsis renderer project.

After learning much more about scons than I'd originally intended, I finally found the following reasonably clean solution. The idea is to override the default Library and StaticLibrary builder objects of the build environment and cause them to compile PIC code. This may be done by passing src_builder = SharedObject rather than StaticObject to the Builder factory function:

import platform

if platform.machine() == 'x86_64':
picLibBuilder = Builder(action = Action('$ARCOM'),
emitter = '$LIBEMITTER',
prefix = '$LIBPREFIX',
suffix = '$LIBSUFFIX',
src_suffix = '$OBJSUFFIX',
src_builder = 'SharedObject')
env['BUILDERS']['StaticLibrary'] = picLibBuilder
env['BUILDERS']['Library'] = picLibBuilder

For some projects it may be desirable to build static libraries from both PIC and non-PIC objects. In that case, instead of overriding the Builder objects as above, you'd probably want to define some new ones, and explicitly call them to produce pic libraries. You'd also want to modify the library name to allow both flavours of static library to coexist without name clashes. I gather the standard way to do this is to append _pic to the library name. Putting this together, you'd have something like:

if platform.machine() == 'x86_64':
picLibBuilder = Builder(action = Action('$ARCOM'),
emitter = '$LIBEMITTER',
prefix = '$LIBPREFIX',
suffix = '_pic$LIBSUFFIX',
src_suffix = '$OBJSUFFIX',
src_builder = 'SharedObject')
env['BUILDERS']['StaticPicLibrary'] = picLibBuilder
env['BUILDERS']['PicLibrary'] = picLibBuilder

Relevant Links

* A helpful discussion about fPIC on the freeBSD ports list
* Shared objects for the object disoriented: an introduction to shared objects at IBM developer works.

Tuesday, October 26, 2010

QT

http://hi.baidu.com/baldwin8/blog/item/10c3fd8e7c0002f6503d92df.html

https://lists.webkit.org/pipermail/webkit-help/2009-August/000193.html

http://www.qtcn.org/bbs/simple/?t18619.html

Monday, October 25, 2010

vmware 网络配置实例二 windows xp host + linux guest

vmware 网络配置实例二 windows host + linux guest
(yunqing(2005-03-24)按:很多朋友问到ping不通host的情况,请检查一下host里的防火墙设置,多数的windows xp sp2下的防火墙都设置成不响应)
前言:前几天写了一个vmware的配置的一个案例,主要关于linux host+windows guest的情况(http://bbs.chinaunix.net/forum/viewtopic.php?t=367907& highlight=yunqing),适用于经常跑linux而把windows当成副业的朋友。发布以后反应不大,后来发现坛子里的朋友使 windows host 来跑linux guest的居多 ,且有很多帖子谈到网络问题,自己想没有那么难吧,就试了一把,把过程写下来希望对网络有问题的朋友有所帮助。
版权属yunqing所有,首发chinaunix.net,转贴引用请包含此行声明

正文:

本人使用的是vmware workstation 4.52,host机器运行的是windows Xp professional ,如果你还在使vmware workstation 4.0建议下载一个升级包,不过我想即使不做问题也不大。

1。安装 vmware workstation,很简单,一路ok过去,相信大部分朋友已经装好。

2。创建新的guest系统。选择类型。因为我以发生问题最多的redhat 9做试验,所以就选redhat linux,选custom,网络接口选hostonly(如果你已经安装好 了,用了nat或bridge也没有关系,在虚拟机的属性里改成hostonly就行了。)

3。创建后启动虚拟机,插入安装rh9的第一张盘。选择定制安装,我只保留了gonme, X, 和graphical internet,节省安装空间和时间。

4。安装过程很顺利,没有问题,完成后重新启动虚拟机,发现在更新fstab的时候挂了起来,估计是连接cdrom活软盘时候超时。kill掉虚拟机,更改设置,把光驱和软盘的autoconnect when power on清除掉。重启虚拟机,没有问题,进入最后设置,声卡,图形界面均没有问题。

5。按照要求在虚拟机里安装vmware-tool,对鼠标和图形进行更好地支持。
如果你在图形界面下,首先要切换到文本模式。
右键点击桌面,打开一个終端
在終端里:
su
#/sbin/telinit 3
图形界面消失,敲回车几下,在文本方式下登录。
在windows的vmware的窗口菜单中选vm->;install vmware tools
在虚拟机中:
su
mount /dev/cdrom /mnt/cdrom
cd /tmp
tar zxf /mnt/vmware-linux-tools.tar.gz
cd vmware-tools-distrib
./vmware-install.pl
回答并设置屏幕分辨率,除了分辨率需要选择外,直接回车就行了。
返回到默认的图形界面(运行级别5)
/sbin/telinit 5

6.登录虚拟机,打开一个終端:
/sbin/ifconfig
发现eth0没有起来。
不要惊慌。
-------------以下是网络设置---------------
7。到windows XP 中,查看所有的网络连接,你应该发现除了原有的网卡之外,又多了Vmnet1和Vmnet8。如果你看了一下说明书应该知道,vmnet1是hostonly的接口,而Vmnet8是使用NAT的网络接口。在这里我们既不想用VMWARE自带的DHCP也不想用他的NAT所以我们知关心VMnet1
在进一步操作之前先说一下idea:
我们将使用hostonly这个网络接口连接虚拟机和主机,然后利用windows Xp/2000里面自带的internet连接共享(实际上是一个简单的路由NAT)来让虚拟机 通过原来的网卡进行外网的访问。
那么为什么不使用桥接的方式呢,我在前一篇文章(linux host + windows guest)里面已经有些讨论,请参考。不过最现实的原因是桥接需要一个不同于 原主机上的另外一个独立的IP地址,这对于有些情况(IP和MAC绑定,网管不同意),比较难办到。
OK, let's go
(1)查看你的连接外网的网卡的属性,选择“高级”标签,设置成允许共享,并设定允许的网络接口为VMNET1,如下图。

(2)再插看一下你的VMnet1 的属性,看一下TCP/IP协议的设置,你发现已经被自动设置为192.168.0.1/255.255.255.0,如下图。

(3)windows下的设置完成,转入到跑linux的虚拟机。将你的eth0的ip地址设置为静态的(如果安装时没有选静态的话)
(4)windows下的设置完成,转入到跑linux的虚拟机。将你的eth0的ip地址设置为静态的(如果安装时没有选静态的话)。
按红帽子图标->系统设置->网络(或其它你了解的方法)
ip: 192.168.0.2(或其它在此网段上的地址)
netmask: 255.255.255.0
default gateway: 192.168.0.1
dns:输入你自己的DNS
保存设置。如果你还没有设置好主机名称:
cd /etc/sysconfig
vi network
编辑HOSTNAME
cd /etc
vi hosts
加入:
192.168.0.2 yourhostname
重新启动服务
su
/sbin/service network restart
(4)测试一下
网关: ping 192.168.0.1
dns: ping dnsserver

另请参阅:

vmware 配置实例一 linux host + windows guest + firewall
http://bbs.chinaunix.net/forum/viewtopic.php?t=367907&highlight=yunqing

vmware 网络设置三:理解虚拟网络的类型
http://bbs.chinaunix.net/forum/viewtopic.php?t=376768&highlight=yunqing

Howto: Ubuntu Linux convert DHCP network configuration to static IP configuration

My friend wanted to know how to change or convert DHCP network configuration to static configuration. After initial installation, he wanted to change network settings. Further, his system is w/o GUI system aka X Windows. Here is quick way to accomplish the same:

Your main network configuration file is /etc/network/interfaces

Desired new sample settings:
=> Host IP address 192.168.1.100
=> Netmask: 255.255.255.0
=> Network ID: 192.168.1.0
=> Broadcast IP: 192.168.1.255
=> Gateway/Router IP: 192.168.1.254
=> DNS Server: 192.168.1.254

Open network configuration file
$ sudo vi /etc/network/interfacesOR$ sudo nano /etc/network/interfaces

Find and remove dhcp entry:
iface eth0 inet dhcp

Append new network settings:

iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254

Save and close the file. Restart the network:
$ sudo /etc/init.d/networking restart
Task: Define new DNS servers

Open /etc/resolv.conf file
$ sudo vi /etc/resolv.conf

You need to remove old DNS server assigned by DHCP server:
search myisp.com
nameserver 192.168.1.254
nameserver 202.54.1.20
nameserver 202.54.1.30

Save and close the file.
Task: Test DNS server

$ host cyberciti.biz
Network command line cheat sheet

You can also use commands to change settings. Please note that these settings are temporary and not the permanent. Use above method to make network changes permanent or GUI tool as described below.
Task: Display network interface information

$ ifconfig
Task: Take down network interface eth0 / take a network interface down

$ sudo ifconfig eth0 downOR $ sudo ifdown eth0
Task: Bring a network interface eth0 up

$ sudo ifconfig eth0 upOR$ sudo ifup eth0
Task: Change IP address and netmask from command line

Activate network interface eth0 with a new IP (192.168.1.50) / netmask:
$ sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0 up
Task: Display the routing table

$ /sbin/route OR$ /sbin/route -n
Output:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
localnet * 255.255.255.0 U 0 0 0 ra0
172.16.114.0 * 255.255.255.0 U 0 0 0 eth0
172.16.236.0 * 255.255.255.0 U 0 0 0 eth1
default 192.168.1.254 0.0.0.0 UG 0 0 0 ra0

Task: Add a new gateway

$ sudo route add default gw 172.16.236.0
Task: Display current active Internet connections (servers and established connection)

$ netstat -nat
Task: Display open ports

$ sudo netstat -tulpOR$ sudo netstat -tulpn
Task: Display network interfaces stats (RX/TX etc)

$ netstat -i
Task: Display output for active/established connections only

$ netstat -e
$ netstat -te
$ netstat -tue

Where,

* -t : TCP connections
* -u : UDP connections
* -e : Established

Task: Test network connectivity

Send ICMP ECHO_REQUEST to network hosts, routers, servers etc with ping command. This verifies connectivity exists between local host and remote network system:
$ ping router
$ ping 192.168.1.254
$ ping cyberciti.biz

See simple Linux system monitoring with ping command and scripts for more information.
Task: Use GUI (Graphical Configuration) network Tool

If you are new, use GUI configuration tool, type the following command at terminal:
$ network-admin &

Above command is Ubuntu's GUI for configuring network connections tool.
Final tip - Learn how find out more information about commands

A man page is your best friend when you wanted to learn more about particular command or syntax. For example, read detailed information about ifconfig and netstat command:
$ man ifconfig
$ man netstat

Just get a short help with all command options by appending --help option to each command:
$ netstat --help

Find out what command is used for particular task by searching the short descriptions and manual page names for the keyword:
$ man -k 'delete directory'
$ apropos -s 1 remove

Display short descriptions of a command:
$ whatis rm
$ whatis netstat

Linux offers an excellent collection of utilities, which can be use to finding the files and executables, remember you cannot memorize all the commands and files ;)

Monday, October 18, 2010

TX31 Compfiling

resource:
http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/shared-libraries.html
http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/opencv-intro.html
http://www.troubleshooters.com/linux/prepostpath.htm
http://www.appistry.com/community/forums/content/cannot-restore-segment-prot-after-reloc-permission-denied
http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

OpenCV2.1
http://opencv.willowgarage.com/wiki/InstallGuide

CMake
http://www.cmake.org/cmake/resources/software.html

Sunday, October 17, 2010

The HID programming

This article is from http://www.lvr.com/hidpage.htm
Resources:
http://www.kadtronix.com/usbhidapi_usr.htm


Basics

My HID FAQ.

HID webpage from the USB-IF.
Windows programming

You can use Windows' built-in HID (human interface device) drivers to communicate with devices that conform to the USB's HID class specification. There's no need for a custom driver; the device uses the drivers included in Windows. Use any programming language that supports calling API functions. The device doesn't have to have a "human interface." Any device that can function within the limits of the HID specification (control and interrupt transfers only) may be able to be designed as a HID.

Microsoft's WDK has documentation for the HID functions and an overview of how to use them. The WDK also includes the header files to use with Visual C++ programs that access HID-class devices (hidsdi.h, hidusage.h, hidpi.h).

Human Input Devices. The Windows HID API from Microsoft.

Microsoft's DirectX technology includes DirectInput, which supports communications with HID-class game controllers (in both directions, in spite of the name), without requiring custom drivers. Microsoft's DirectX Developer Center has the latest info.

Use Raw Input to read data from a specific keyboard, mouse, or game controller.

A Usenet discussion about using HIDs under Windows CE. For other posts on this topic, search the newsgroups microsoft.public.windowsce* from groups.google.com/advanced_search.
Articles

HIDs Up by Jan Axelson, Embedded Systems Programming. From Embedded Systems Programming.

Using the HID class eases the job of writing USB device drivers by Stuart Allman. From EDN.

Making USB C# friendly. Article by Ashley Deakin in VSJ.
Books

USB Complete includes three chapters on HID firmware and application programming.

Chapter 13: Human Interface Devices. From Programming the Microsoft Windows Driver Model, Second Edition by Walter Oney.

Tools

Software

HIDMaker creates device firmware and a Windows application from information you provide. Also available are the AnyHID test program and the USBWatch software-only protocol analyzer. From Trace Systems Inc.

The SimpleHIDWrite utility tests HID-class devices. The HidTest utility also tests HIDs with a variety of API calls. HidTest.zip contains the application and HidTestSource.zip contains the source files in Delphi. All from Robert Marquardt.

Robert Marquardt's HID Controller component suite for Delphi.

USB HID API Function Library. From Kadtronix.
Hardware

MouseWarrior, KeyWarrior, JoyWarrior, IO-Warrier, and IO-Warrior 24PowerVampire (for using USB as a power supply). Available as programmed chips or kits. From Code Mercenaries.

My example code

Host applications and device firmware to work with them. Thank you to everyone who has helped by contributing bug reports and often the fixes along with them.

Host applications

My HID applications below communicate with generic (custom) HIDs. Each supports exchanging Input, Output, and Feature reports and shows how to search for devices that use a particular interface GUID. All except the Visual Basic 6 code show how to use RegisterDeviceNotification and WM_DEVICE_CHANGE messages to detect when a device is attached or removed.
Visual Basic .NET

generic_hid_vb. Created with Visual Studio 2008 for the .NET Framework 2.0 or later. Updated 1/12/10.

Visual C# (C Sharp)

generic_hid_cs. Created with Visual Studio 2008 for the .NET Framework 2.0 or later. Updated 1/12/10.

usbhidio_V2.3.cs. My VB HIDClass application ported to C#. From Gordon Vance. (Bug report: change: if (MyEnvironment.Version >= Version98SE) to if (MyEnvironment.Version <= Version98SE).

Visual Basic 6

Usbhidio2

Visual C++ 6

Usbhidio_vc6. This project will load into and run in Visual Studio. The project requires the header files hid.lib, hid.h, and hidsdi.h from the WDK.

1. If you get this errror on attempting to compile:

DBT_DEVTYP_DEVICEINTERFACE, PDEV_BROADCAST_DEVICEINTERFACE, HDEVNOTIFY, DEVICE_NOTIFY_WINDOW_HANDLE undeclared

Set WINVER = 0x0500 or higher in stdafx.h

For more info, go to groups.google.com and search on:

"DEV_BROADCAST_DEVICEINTERFACE" "undeclared identifier"

2. HidD_GetInputReport and HidD_SetInputReport require Windows XP or later.

Generic HID device firmware

HID firmware for communicating with the Windows host code above.
Microchip PIC18F4550

pic_usb_device_hid_generic_10.zip is is my Microchip PIC microcontroller firmware for generic HIDs. Written for the PIC 18F4550 and Microchip's MPLAB C18 compiler with the Microchip Application Libraries V2.6a. See the readme file to find out how to create the project in the Framework directory structure. (The Framework includes a HID example, but my code also supports vendor-defined control transfers.) Updated 4/22/10.
Older versions

Use the newest Framework and firmware unless you have a compelling reason not to.

For the Framework V2.5. generic_hid_fsusb_fw2-5.zip
For the Framework V2.3. Generic_HID_c18_fsusb_fwv2-3.zip
For the Framework. V2.1. Generic_HID_C18_FSUSB
For the Framework V1.x. mchpfsusb_ghid.zip

Cypress Semiconductor EZ-USB FX2

fx2hid.zip runs on Cypress' FX2 EZ-USB chips at full and high speeds. It's adapted from Cypress' frameworks examples and requires the full version of the Keil C compiler.

Cypress Semiconductor Encore

Enchid.zip for Cypress Encore chips (CY637xx). Assembly code.

Cypress Semiconductor EZ-USB

fwhid.zip for Cypress EZ-USB chips. In C. More information.

Cypress Semiconductor EZ-USB Buttons and Lights

A version of John Hyde's buttons and lights code for the USBSimm module. (The module is no longer available.) My code supports interrupt Out transfers for Output reports.

Cypress Semiconductor CY63000

Usbhidio.zip (61k) contains assembly-code firmware and host software for communicating with a Cypress CY7C63000 microcontroller (obsolete). The code runs on Cypress' 3650 Developer's Kit and CY3640 Starter Kit. Cypress has discontinued the Starter Kit. The Hi-Lo EPROM programmer included in the Starter Kit was Cypress part CY3649. The host software is Visual Basic 6 code. Bug list and fixes for usbhidio.

Cypress Semiconductor CY63000 firmware plus Visual Basic code using an ActiveX Exe server

HIDDemo2.zip (70k) is an enhanced version of usbhidio. Like usbhidio that uses an ActiveX Exe server to handle reading from the device.

Other code

Code from other sources.
Device firmware for use with my .NET HID applications

These firmware examples are designed to work with my PC HID applications above.
Cypress Semiconductor 66113

Hidhub1.zip contains a version of my generic HID-class firmware for Cypress' CY7C66113 hub & peripheral chip. The firmware enumerates as a compound device made up of a 4-port hub and my usbhidio device. It runs on the 3652 development kit and will communicate with my hidvb and usbhidioc software. This code is provided by Mat Laibowitz.

Microchip PIC

Firmware for the PIC16C745/765 to enable using my HID .NET and usbhidioc software. From Microchip. For more PIC advice, see USB and PIC Microprocessors 16C745 and 18F2455 from Alan Macek.

Assembly code and C firmware for the PIC16C745 and PIC18F2455. From Bradley A. Minch at Olin College

The PICBasic Pro Basic compiler includes instructions to perform HID communications, for use with PICMicros with USB support. From microEngineering Labs Inc.

My Very First USB Peripheral. A description of a PIC16C745 HID project. From Technology Stir Fry.

More HID firmware
Atmel

Atmel's AT90USBKey demonstration board for the AT90USB AVR microcontroller has generic HID, keyboard, and mouse applications.

Automator is a HID project for the Atmel AVR-USB. Includes host code. From Objective Development Software.

Cypress Semiconductor

Example HID Firmware in C for Cypress enCoRe devices. From Stephen Santarelli.

John Hyde's USB Design By Example site has HID examples in Visual Basic and Visual C++. I have a version of the buttons and lights firmware that supports interrupt Out transfers.

The MO1002 USB to UART is a HID device that translates between asynchronous serial data and USB using Windows' HID drivers. Includes schematics, firmware, and a Visual C++ application. The chip used is Cypress' CY7C63001. From Moto Development Group.

Microchip

Microchip's USB Framework firmware includes HID examples..

FMSUSB is a RC(PPM) to FMS (Flying Model Simulator) USB interface. Uses a PIC16C745. From Walter Zanette.

A firmware-only HID (no hardware device controller) using a Microchip 16F84A to control a parallel LCD module (HD44780 compatible) via USB. (Spanish)

RcJoystick NG is an interface between a USB port and the buddy box connector on many RC Transmitters. From Alessio e Andrea.

ST-Ericsson (formerly NXP Semiconductors/Philips)

Interfacing a Game Boy Advance to a PC using a PIC16F877 and PDIUSBD12. From Rob Meerman.

Host code

HID USB Driver / Library. A C# DLL. From Florian Leitner.

USB Hid Device Library for .NET. From Mike O'Brien.

HID component for C# .NET. A project from the Avans Hogeschool in The Netherlands.

Controlling the Logitech iFeel Mouse. Experiments with force feedback. Daniel C. Moore

Friday, October 15, 2010

Compiling Software With Debian Linux

Note: There are many sources available which cover patching and upgrading the kernel. It involves downloading patch files or the Linux kernel source code and compiling a new kernel. This is not the best practice to follow on most Linux systems. Most distributions customize the kernel. Any such customizations would be lost if you do a generic kernel upgrade.

Upgrading the kernel on your Debian system can be done easily (kind of) using the the apt package tool to install a "kernel-image" package. The main reason for upgrading a kernel is to support a new piece of hardware or implement some new function. Note that the Debian CDs offer numerous newer kernel packages. If none of the newer kernels on your CDs don't support some new hardware or function, implement the new hardware driver or function by using a loadable module rather than by upgrading your kernel. Loadable modules are discussed on this page.



There is a lot of free software out there that is written for Linux/UNIX that's only available in source code format. As explained on the Basics page, this is the most efficient way for the developers to distribute their software. When you obtain the source code file(s) you compile them to generate an executable binary that's specific to your OS and hardware platform. Knowing how to compile source files is an indispensible skill in the Linux/UNIX world so we'll dedicate a good part of this page to it.

As mentioned on the Packages page, compiling programs can be a frustrating experience. You can run into all kinds of errors due to outdated library files, certain assumptions made by the programmer (which don't hold true on your system), and numerous other causes. Save yourself some grief and use packages whenever possible or at least use pre-compiled binaries if they're available for your particular system. On the bright side, the fact that Debian is distributed with over 14,000 packages you'd be hard-pressed to find something that isn't available as a package. Having said that, if all you can get is the source code, get that and press on.

There's actually two steps involved in generating an executable binary from a source file, compiling and linking. Most programs, whether written for PCs or mainframes, act pretty much the same way. They'll make "calls" to the operating system for specific "services" like "Give me the current date" or "Tell me which user is running this program". It would be a pain if programmers had to write the same code over and over again in every program they wrote to handle these common functions. To address this there are things called "libraries" that contain the code for tons of these routine tasks. Instead of writing the actual code to do a task, programmers simply add references to these library routines (often referred to as "function calls") in the source code of their program. Each of these routines (or "functions") has a unique name, and the programmer uses this name in their reference.

Once a programmer has written the source code for a program, which you may recall from the Basics page is in a human-readable text file format, they "compile" it using a compiler program. Each programming language has its own compiler (or several of them). The compiler program reads the text source code file as input and spits out a binary file called an "object" file. It's merely a binary (machine-readable) version of the programmer's soure code file, complete with those references to library routines.

The next step is called "linking" and it's where those library references are taken care of. The linker is also just another program. It reads in several files, the object file that was generated by the compiler and one or more library files. Every time the linker finds a reference to a library routine in the object file, it reads the library files and finds that routine. It then replaces the programmer's reference with the code for the routine from the library file. After it has replaced all the references with code from the library files the linker then spits out the executable binary file.

Compiling a program

In Linux, the make utility handles compiling and linking. When you run the make utility you'll see lines that start with gcc which stands for GNU C Compiler. You may also see error messages with the words:

unresolved symbols

This means that the during the linking process a library routine that is referenced in the object file couldn't be found in any of the library files. This may indicate that your library files are out of date or you're missing a library file. Later in this page you'll use the apt utility to add a package which contains a library file because a routine in it is referenced by the source code we use.

Another common reason for errors when trying to compile drivers is that the kernel source code and/or header files are not present. If you plan on compiling drivers for devices (such as the Logitech QuickCam) that don't have a driver included with Debian, you'll need to install those packages before you compile the drivers. (See the Going Modular section below.)

So where does all this compiling and linking take place? Most Linux systems have a /usr/local subdirectory. The "local" refers to things that are specific to the local machine. In other words, if a particular program isn't installed on all Linux systems by default, then it represents something that is additional to that particlar local machine. So most third-party programs and utilities should be installed under this /usr/local subdirectory.

There are quite a few subdirectories under the /usr/local subdirectory. Two of them are /usr/local/src (for source code files) and /usr/local/bin (for binaries). The make utility will usually put any newly-compiled binaries in the /usr/local/bin directory.

With Linux, you typically issue four commands to compile, link, and install a program:

./configure (may not have this)
make
make install
make clean

configure is usually an extremely long and hideously complex shell script that the program's author (hopefully) generated to make your compiling experience easier. It basically checks out your system to see what you have and where it is and to make sure it has everything it needs. I have also seen this same type of script given the name of the program or driver with a .sh extension (example 'myprogram.sh' instead of 'configure'). However, such scripts are no guarantee of a successful compile. Such a script may also create a thing called a "makefile" that is used by the make utility in the next step.

The make utility is what does the actual compiling and linking. If it's going to bomb, this is where it will bomb.

make install puts the compiled binary file in the proper (/usr/local/bin ) subdirectory.

make clean cleans up temporary files that were generated by the compiling and linking processes.

Now that you know what you'll be doing, and how to do, lets compile a program. (Even though compiling is only one step in the process, the term "compile" is often used to refer to the entire process of compiling, linking, and installing.)


Programs and Utilities Top of page

If you're not familier with IRC (Internet Relay Chat), it's like an on-line chat room that you can access using an IRC client. Organizations or individuals will set up IRC servers that those with IRC clients can access and hold on-line, real-time discussions. You can see everything that all other chat members type into their IRC client and everyone else can see everything you type into your IRC client.

Since one of Debian's support options is via an IRC chat room, we'll use the source code for an IRC client for our example. The IRC client we'll use is called ScrollZ (www.scrollz.com). It is a "console" client, meaning it runs in the character-based interface of a shell. No GUI is required. However, it does use a thing called ncurses (also sometimes referred to as just "curses") which allows graphical-type displays on the console screen.

While several ncurses packages are already installed on your system, one is missing. (Found that out through one of those frustrating compiling experiences I was talking about.) It's a library file that contains a routine called tgetent that the linker looks for because it's referenced in the source code. We'll need to add the package that contains this library file. Naturally, your Debian system will need Internet connectivity so you can FTP the ScrollZ tar ball to your system (you'll see how below) or you can download it using a different system and FTP it to your Debian system.

Install the needed ncurses package (off of CD #3) using the command:

apt-get install libncurses5-dev

The next step is to download the ScrollZ client source code tar ball. When you are going to ftp a source code tar ball to your system, you'll want to be in the appropriate subdirectory before you initiate the transfer so that it ends up in the right spot. As such, we use the following two commands to start the process of downloading the ScrollZ source code tar ball:

cd /usr/local/src
ftp ftp.scrollz.com

Enter anonymous when prompted for a user name and your e-mail address when prompted for a password. (This is just customary, they're not collecting e-mail addresses so they can spam you.) Once you're logged in, download the ScrollZ source tar ball using the following commands at the ftp> prompt:

cd pub/ScrollZ/source
ls
get ScrollZ-1.9.3.tar.gz
quit

The ls command will show you what files are available. By the time you try this the ScrollZ-1.9.3.tar.gz may no longer be available so just download the latest version file that ends with the .gz extension. You'll see a line that says:

150 Opening BINARY mode data connection...

and it will just seem to sit there. The file is downloading. There's just no progress indicator.

As mentioned back on the Basics page, when you extract a tar ball it extracts to the same directory structure that was tar-ed. Many tar balls do contain subdirectories. The convention is that the parent directory has the same name as the downloaded file, minus the .tar.gz stuff. (This isn't always followed however.) So if we use the following command to extract the tar ball we just downloaded:

tar -zxvf ScrollZ-1.9.3.tar.gz

we'll end up with the following subdirectory:

/usr/local/src/ScrollZ-1.9.3

which will contain the extracted contents of the tar ball. If we use the commands:

cd ScrollZ-1.9.3
ls -laF

we'll see these contents. You will see several things here that are common practices with source tar balls. You will typically see documentation files with names like (or start with) README which normally contains general information about the program and INSTALL which has instructions for installing the program. (The names being in upper-case is also common for documentation files.) These are text files that you can read with any text editor. There is often also a /doc or /documentation subdirectory with more text file documents like a user manual. If you run into problems installing a program the first place you should look is the documentation files, especially anything related to installation. ScrollZ's INSTALL.ScrollZ installation documentation file is located in the /doc subdirectory.

We see that there is (thankfully) a configure shell script. So as mentioned above, the first command we use is to run this shell script. We precede the name of the shell script with a ./ because the subdirectory it's in isn't in our system's path. So type in:

./configure

and you'll see a ton of text go flying by on your screen. At the end of all of it will hopefully (instead of an error message) be some text telling you to do a 'make'. Just because it tells you do to a make doesn't mean you should. Use the Shift-PageUp key combination to look for lines with "could not find" or "cannot locate" in them. These lines typically list a function name that couldn't be found in any library and you'll need to find out what library is needed before proceeding. If no such lines exist (which they shouldn't because we downloaded the additional library earlier), we can do a make:

make

You may see some warning messages during the compiling process. If any of them are serious enough to be a show-stopper the compile will bomb out with error messages. Otherwise, it will complete successfully with a lot of stuff on the screen.

Next we do a:

make install

to install the files in their respective directories. Then, finally, a:

make clean

Thats it! You've compiled and installed a program from source code. Now you can make sure the program is in the path by typing in:

whereis scrollz

and we see that it's in the:

/usr/local/bin

directory (where the make install put it). Actually, the scrollz file is just a symbolic link to an executable binary named scrollz-1.9.3 which is in the same directory.

Before we run the program we have to set up a few environment variables and files. First we'll add the environment variables to our profile so that we don't have to manually set them every time we use the program. Open your profile file with the command:

nano ~/.profile

(recall that the ~ character represents the path to your home directory) and add the following three statements:

IRCNICK="penguin"
IRCSERVER="irc.debian.org"
export IRCNICK IRCSERVER

Use whatever nickname you want for yourself in place of penguin but make it somewhat unique (and short). Then exit the editor saving the file.

Next, create a directory that the program looks for inside your home directory using the command:

mkdir ~/.ScrollZ

Create an empty 'save' file in this new directory with the command:

touch ~/.ScrollZ/ScrollZ.save

Now, using a text editor, create an empty "rc" file that the program looks for in your home directory (make sure the name starts with a period) with the command:

nano ~/.scrollzrc

and enter the following statement into this file:

set load_path ~/.ScrollZ

Exit the editor saving the file. (Almost done.) Now you can either reboot the system or manually add the above variables to the current running environment using the following commands:

IRCNICK="penguin"
IRCSERVER="irc.debian.org"
export IRCNICK IRCSERVER

That takes care of the program's setup. If you're not still connected to the Internet, reconnect now. Since the program is in our path, all we have to do to run it is type in:

scrollz

You'll see an error saying that it couldn't open the ScrollZ.save file with the cursor flashing in the lower-left corner of the screen. Now that you're in the program, you'll be entering IRC (and some ScrollZ) commands, not Linux commands. Enter the following command:

/sve

and press Enter to create the file and save the settings.

You're now connected to debian.org's IRC server but you have to enter the Debian room. To do that, enter the IRC command:

/join #debian

You're in! Anything you type on the line below the blue bar (where the cursor is currently flashing) will be displayed in the room (after you press Enter). That's why you have to start all IRC commands with a slash (/) character. Those aren't displayed as chat. The lj on the right side of the blue bar stands for "last joined" and your nickname will be there until someone else joins the room after you.

So what if you're in the chat room and you want to try something at a shell prompt? Just press the Alt-F2 key combination to get to a different console. Pressing Alt-F1 will take you back to the console your chat session is in.

The following IRC commands will be helpful during your chat sessions:

/join #room-name
/leave #room-name
/quit parting message to participants
/msg individual-participant-nickname private-message
/whois your-nickname
/whois another-participants-nickname

Note that /quit exits the ScrollZ program in addition to leaving the room.

When the room is busy it's best to begin messages intended for a specific particpant with that participant's nickname. When asking for help with a problem, be as specific as possible and supply as much relevant information as possible.

That's the good news. Now the bad news. In many cases the above compiling/linking/installing procedure won't do you any good. Many source tar balls don't contain a configure shell script. In that case all you can do is look for documentation files or Web pages on the author's Web site for compiling and installation information. In some cases the author may assume those using their program are experienced Linux/UNIX administrators and won't offer much in the way of documentation. If this is the case, e-mail them asking for more specific instructions. Their e-mail address or the URL to their Web site will likely be given in one of documentation files.

Drivers

That's compiling a program. The other big thing that often needs compiling are drivers. Most drivers compile into driver "modules" which we explain in the next section.

Let's look at the driver for the popular 3Com 3C509 NIC. The source code for the driver is available at www.scyld.com/network/3c509.html. Near the bottom of the source code file are the following commented lines:

/*
* Local variables:
* compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -c 3c509.c"
* version-control: t
* kept-new-versions: 5
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
* End:
*/


Notice that the command needed to compile the driver is given in these comments. However, also on the above Web page, right next to the link for the driver source code, is a link on how to set the driver up as a module. Any author or company that makes driver source code available should supply you with similar information either as comments in the source code, in an accompanying README file, or on a Web page. If they don't, e-mail them asking for it. If they get enough e-mails perhaps they'll find it beneficial to create a README file or Web page.


Going Modular Top of page

One of the things the kernel has to do is interface with certain pieces of hardware. Like other operating systems, these pieces of hardware have their own individual software drivers. One of the reasons the kernel has grown in size over the years is that more and more drivers for more and more hardware devices have been compiled into the kernel.

With all of the new hardware coming out, trying to compile in all of the available hardware drivers would result in a huge kernel that takes up a good chunk (if not all) of your system's memory. While it may make sense to compile certain drivers into the kernel (like IDE and SCSI hard-drive controller drivers), the majority of hardware drivers can be compiled as loadable modules and dynamically added to the running kernel as needed.

In addition to hardware device drivers, modules are also developed for new filesystems and new kernel routines like data encryption. Adding modules does not increase the size of the kernel. They merely take up more disk space (and more memory if they are loaded).

By modulizing drivers you reduce the size of the base kernel which cuts down kernel memory requirements. Using modules is also safer. If you compile a new driver into a kernel there's no way to get it out. If there's a bug in it you're pretty much screwed. You'd have to roll back to your previous kernel. Being able to manage loadable modules means that if you load a new module and it causes problems, you simply unload it.

The nice thing about modules is that if you do find yourself needing to add some new drivers or new functionality to your kernel you can do it without patching or replacing the kernel source code and recompiling everything. Loadable modules are like adding code to a running kernel.

These days drivers are all written loadable modules and a lot of times a driver module is only available in source code format (sourceforge.net provides access to many of these). Compiling a driver module isn't much different than compiling a program. You'll just end up with a file with a .o extension (the letter 'O' - not zero).

Note: The source code for many driver modules requires access to the kernel source code or just the kernel headers during the compilation process. You are not recompiling the kernel. It's just that the driver needs access to certain kernel header, source, etc. files.

If unsure what is needed by a specific driver, try compiling it with just the header files first. Debian includes a lot of "kernel-header" packages on the binary CDs. Enter the command:

apt-cache search kernel-headers

to see all of them. It's IMPORTANT that you install the one that matches the kernel you're running. Enter the command:

uname -a

to find out what kernel version you're running and install the header package that matches it exactly (it may differ depending on the processor in your system). On my system it was:

apt-get install kernel-headers-2.4.27-1-386

If the kernel source code is needed you can get that off of the binary CD set as well. Note that the kernel source tar ball is about 180 meg in size so you'll want to use the df -h command to make sure you have about 400 meg free on your hard-drive before you install the kernel source. Use the command:

apt-get install kernel-source-2.4.27

to load the kernel source off the Debian binary CD set onto your system. Note that this installs a single BZIP (compressed) file of the source code into the /usr/srcdirectory. You have to first unbzip it with the command:

bunzip2 kernel-source-2.4.27.tar.bz2

(It'll take awhile.) Then you have to untar it to create the kernel source tree using the command:

tar -xvf kernel-source-2.4.27.tar

You can delete the .tar file after the extraction to free up some disk space.

The utilities you use to manage modules are contained in the modutils package. These utilities include:

* lsmod - lists currently loaded modules
* insmod - inserts modules into the kernel
* rmmod - removes modules from the kernel
* modprobe - a better alternative to insmod because it checks for dependent modules
* depmod - builds a file which contains the dependency information used by modprobe


There are other utilities but these are the most commonly-used. They are all executable binary files and all are located in the /sbin directory.

An important point to remember is that modules may be specific to a kernel version or at least a given kernel version and higher. If a module wasn't written for your kernel version you'll get an error when you try and load it. Module file names end with a .o and are located in a subdirectory that has a parent directory with a name that includes the Linux kernel version. For example, the module files on a Debian 3.1 system are in subdirectories similar to:

/lib/modules/2.4.27-1-386/kernel/drivers/ide
/lib/modules/2.4.27-1-386/kernel/drivers/net
/lib/modules/2.4.27-1-386/kernel/drivers/video

In addition,

/lib/modules/2.4.27-1-386

is also where the file modules.dep file is located. The modules.dep file is where the module dependecy information generated by the depmod utility is stored and accessed by the modprobe utility.

For the curious, if you go looking through the system's startup files looking for insmod or modprobe commands you won't find any. One of the scripts in the /etc/init.d subdirectory that's called pretty early in the sartup process is the kerneld shell script. The kerneld shell script calls the /sbin/kerneld executable binary that causes modules to be auto-loaded as they're needed. In addition, optional modules listed in the /etc/modules file are also loaded.

If you boot your system and use the Shift-PageUp key combination to look at the messages generated early in the boot process, you'll see modules start to get loaded shortly after the init process starts.

It's at system startup where you're most likely to see module-related messages and errors. The most common one starts out:

insmod: /etc/modules.conf is more recent than....

This isn't really a problem, just a file date issue. Most of the time it'll just disappear in the course of using your system.

Compiling A Driver Module

Back on the Webcam page we found that Debian doesn't come with a driver for the popular QuickCam USB camera. There is a driver for it on sourceforge.net called qc-usb. This driver comes with a script that checks for certain things and contains the necessary compile commands. Before proceeding Make sure you've installed the kernel header files as explained earlier.

You can download the driver using the FTP utility on your Debian system (as we showed above for the ScrollZ program file) or download it using another system and FTP it to your Debian system. If you do the later you probably FTPed it up to your user home directory so you'll need to copy the file to the proper directory with the command:

cp /home/keith/qc-usb-0.6.2.tar.gz /usr/local/src

Then go into the /usr/local/src/ subdirectory and enter the command:

tar -zxvf qc-usb-0.6.2.tar.gz

and a /usr/local/src/qc-usb-0.6.2 subdirectory will be created and contain all of the files. If you list the files in the directory you'll see the quickcam.sh file which is the setup script written by the driver developer in an attempt to make creating the driver module easier for you.

Be sure you have the cam plugged in at this point. We need to supply to the quickcam.sh script with the location of the kernel header files we installed earlier. To run the script and supply it with this information we use:

./quickcam.sh LINUX_DIR=/usr/src/kernel-headers-2.4.27-1-386

It'll start out by checking for files and utilities. Disregard the warning about exporting kgcc. It'll then warn you that you shouldn't run as root but we're going to do it anyway since later in the script it would ask for the root password if we weren't.

At one point you'll see a bunch of insmod error messages. It's just trying to find out what type of USB circuitry you have and they can be ignored. Eventually you'll see a bunch of gcc compiler commands and when it's done the script will try and load the driver. When you see the line:

Name : Logitech QuickCam USB

several lines above the prompt to press Enter to continue, press Ctrl-C to exit the script. This is because we're not running a GUI. The script didn't do one thing. It didn't copy the driver to the proper location to have it auto-load during system bootup (if the cam is connected to the system when it boots up). To do that, use the command:

cp quickcam.o /lib/modules/2.4.27-1-386/kernel/drivers/usb

That's it! Reboot the system and enter the lsmod command at the shell prompt and you should see the quickcam driver loaded. Now that you have the driver auto-loading you can return to the Webcam page to continue setting up your cam server.

Unfortunately not all driver modules include setup scripts but at the very list there should be documentation available that tells you how to compile it. (Be sure to put the final .o driver file into the correct subdirectory under the /lib/modules/2.4.27-1-386/kernel/drivers directory.) The one downside to a script is that the person that wrote it may make certain assumptions about file locations, etc. that aren't true and the script may bomb out. If a script does bomb don't assume the driver won't work on your system. Try using the documentation to compile the driver manually before you give up.

Monday, October 11, 2010

Tomcat中URL大小写问题

Tomcat中URL大小写问题
今天遇到个客户,强力要求我们软件开发人员把Tomcat设置成为URL地址大小写不敏感。

经过在网上查资料,有一个办法可以做到。就是在context.xml文件中对元素
Context定义设置caseSensitive="false"属性。

但是为了保险起见,我又到Tomcat官方网站去查元素Context定义的官方资料。官方资料的原文参考http://tomcat.apache.org/tomcat-6.0-doc/config/context.html。

caseSensitive

Deprecated. This option will be removed in Tomcat 7 onwards where the default of true will always be used.

If the value of this flag is false, all case sensitivity checks will be disabled. If not specified, the default value of the flag is true.

NOTE: This flag MUST NOT be set to false on the Windows platform (or any other OS which does not have a case sensitive filesystem), as it will disable case sensitivity checks, allowing JSP source code disclosure, among other security problems.

翻译过来就是:
caseSensitive已经过时。该选项将在Tomcat7中被删除,默认值只能一直为true。

如果这个标志值被设置为false,所有大小写检查将被禁用。如果没有特别指定,默认值的标志是true。

注意:这个标志禁止在Windows平台上(或者其他任何不区分文件大小写的操作系统)设为false,因为它会禁用大小写检查,允许JSP源代码泄漏,以及其他安全问题。

搞了半天,如果你是商用系统而且运行在Windows平台上,一定要说服用户URL地址必须大小写敏感,否则会造成一系列安全问题,造成不必要的经济损失。

Thursday, October 7, 2010

原 RHEL5 vsftpd 配置

# cd /etc/vsftpd/
# vi vsftpd.conf
禁止匿名用户
anonymous_enable=NO
禁止所有本地用户变更目录
chroot_local_user=YES
启用可以变更目录的用户列表文件
chroot_list_enable=YES
文件中的用户可以变更目录
chroot_list_file=/etc/vsftpd/chroot_list
# touch /etc/vsftpd/chroot_list
# vi /etc/vsftpd/chroot_list
启动服务
# service vsftpd start
服务自动启动
# chkconfig vsftpd on
# chkconfig vsftpd --list

Turn on vsftpd ftp service
Type the following command:
# chkconfig vsftpd on
How do I start vsftpd ftp server?
Type the following command:
# service vsftpd start
How do I stop vsftpd ftp server?
Type the following command:
# service vsftpd stop
How do I restart vsftpd ftp server?
Type the following command:
# service vsftpd restart

Wednesday, September 22, 2010

red hat Enterprise Linux Server 5.3安装tomcat和java

2009-10-30 17:17

安装前的准备,先下载以下两个文件,不知道是不是版本原因,刚开始试过另外一个版本,结果不成功,就换了新点的版本,推荐以下两个版本

1、java版本jdk-6u1-linux-i586.bin

2、tomcat版本apache-tomcat-6.0.16.tar.gz

首先安装java,如果要安装在/usr/local/ 里就把jdk-6u1-linux-i586.bin复制到/usr/local/这个目录,然后输入命令#chmod 755 jdk-6u1-linux-i586-rpm.bin,添加执行的权限,在执行命令#./jdk-6u1-linux-i586-rpm.bin在这个过程中,要按几次回车,然后输入YES就安装完成了,会在/usr/local/这个目录下多了一jdk1.6.0_01的目录,这个目录就是java的安装目录了。然后设置环境变量,有两种,1. 修改/etc/profile文件,用文本编辑器打开/etc/profile在profile文件末尾加入:

JAVA_HOME=/usr/local/jdk1.6.0_01
      PATH=$JAVA_HOME/bin:$PATH
      CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib
      export JAVA_HOME
      export PATH
      export CLASSPATH

export CATALINA_BASE=/usr/local/tomcat

export CATALINA_HOME=/usr/local/tomcat

    ·注解
      a. 你要将/usr/local/jdk1.6.0_01改为你的jdk安装目录
      b. linux下用冒号“:”来分隔路径
      c. $PATH / $CLASSPATH / $JAVA_HOME 是用来引用原来的环境变量的值
        在设置环境变量时特别要注意不能把原来的值给覆盖掉了,这是一种
        常见的错误。
      d. CLASSPATH中当前目录“.”不能丢,把当前目录丢掉也是常见的错误。
      e. export是把这三个变量导出为全局变量。
      f. 大小写必须严格区分。

  2. 修改.bashrc文件
    
    这种方法更为安全,它可以把使用这些环境变量的权限控制到用户级别,如果你需要给某个用户权限使用这些环境变量,你只需要修改其个人用户主目录下的.bashrc文件就可以了。

    ·用文本编辑器打开用户目录下的.bashrc文件
    ·在.bashrc文件末尾加入:

export JAVA_HOME=/usr/local/j2sdk1.4.2_04
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
export CATALINA_BASE=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat

最后安装tomcat,首先解压#tar zxvf apache-tomcat-6.0.10.tar.gz ;//解压 ;#cp -R apache-tomcat-6.0.10 /usr/local/tomcat ;//拷贝apache-tomcat-6.0.10到/usr/local/下并重命名为tomcat

/usr/local/tomcat/bin/startup.sh; //启动tomcat
显示 Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TEMDIR: /usr/local/tomcat/temp
Using JAVA_HOME: /usr/java/jdk1.6.0_01

到此tomcat已经安装完成,现在使用浏览器访问 http://localhost:8080,出现tomcat默认页面,说明已经安装成功

如果我想让Tomcat开机自动加载怎么办呢?好,往下看吧!

Tomcat安装目录下的bin目录有两个脚本分别用来启动和停止Tomcat,分别是startup.sh, shutdown.sh,你可以用这两个脚本来手工启动和停止Tomcat服务并进行安装后的测试。

我们最简单的方法就是通过startup.sh来自动启动Tomcat,编辑/etc/rc.d/rc.local 增加内容(假设JDK目录是/usr/jdk,Tomcat目录是/apache/tomcat)

export JDK_HOME=/usr/jdk
export JAVA_HOME=/usr/jdk
/apache/tomcat/bin/startup.sh


[root@tpwb ~]# vi /etc/rc.d/rc.local


#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
export JDK_HOME=/usr/java/j2sdk1.4.2_04
export JAVA_HOME=/usr/java/j2sdk1.4.2_04
/usr/local/jakarta-tomcat-5.0.28/bin/startup.sh

这个是我的目录的

这样在系统重启后就可以自动启动Tomcat

Thursday, September 16, 2010

How to convert your laptop into a Wireless HotSpot?

What do I need to set a HotSpot?

1. Active Cable Internet
2. Laptop
3. WiFi on Laptop
4. Wired net connection

Once you have all the above things mentioned, you are all set to follow the steps:

How to setup HotSpot on Windows Vista:

1. Got to Control Panel
2. Click on “Network and Sharing Centre”
3. Under Tasks choose “Setup New Connection”
4. Wireless “Ad-hoc network”
5. Now type in a “Network Name”
6. Choose “WEP” password if you don’t want to share the connection with the entire world
7. Click “Internet connection sharing”
8. Done!

Now a WiFi enabled machine will be able to connect to the network you have just setup with the WEP password

Lets setup a HotSpot on a Windows XP machine:

1. Go into Control panel
2. Open “Network Connections”
3. Right click on "Wireless Connection" and click on "Properties"
4. Click on the "Wireless Networks" tab and select the check-box which says “Use Windows to configure my wireless network settings”
5. Under “Prefered networks” click “Add”
6. Type a name in “Network name” text box
7. Select “Shared” from the options under “Network Authentication”
8. Under Data encryption select “WEP” and type in your password in “Network Key” field and now click "OK"
9. Now the new HotSpot should show in the list of preferred networks.
10. Click on the “Advance” button and select “Computer-to-computer (ad hoc) networks only" and press close
11. Hit “OK”, we are done with the wireless connection properties

One more step, we have to change something in the wired connection setting so that it knows that it has to share connection with the computers accessing our HotSpot.

1. Go to local Area Connections, right click it and select properties
2. Go to the “Advanced” tab and under Internet Connection Sharing check the box which says “Allow other network users to connect through this computer’s internet connection” and make sure the box under that is NOT selected so that no one can disable the network remotely.
3. Hit “OK”

I hope this helps setting up a wireless connection without a WiFi router. Have FuN!

Monday, August 16, 2010

How to get device IMEI number using JavaME for different vendors?

The International Mobile Equipment Identity (IMEI) is a number unique to every GSM, WCDMA, and iDEN mobile phone, as well as some satellite phones. It is usually found printed inside the battery compartment of the phone. It can also be displayed on the screen of the phone by entering *#06# into the keypad on most phones.

To retreive same information using JavaME is as follows:
As you all know that, MIDP (Mobile Information Device Profile) when combined with CLDC provides a Java Runtime Environment and a rich set of Java APIS for cell phones. MIDP defines some System properties that are available to the midlet with java.lang.System.getProperty(...) method. As IMEI is manufacturer specifc so there are few manufacturer specific APIs using which you can retrieve this info. Here's how to get IMEI number from mobile devices of different manufacturers:

1. Nokia
* System.getProperty("phone.imei");
* System.getProperty("com.nokia.imei");
* System.getProperty("com.nokia.mid.imei"); //especially for S40 devices
2. Note: Requires signed MIDlet. S60 3rd edition device does not requires signing to fetch this info.On Series 40 phones this requires that your MIDlet is signed to either operator or manufacturer domain, and this is only available in Series 40 3rd Edition, FP1 devices and newer. Sony Ericsson
* System.getProperty("com.sonyericsson.imei");
3. Samsung
* System.getProperty("com.samsung.imei");
4. Motorola
* System.getProperty("IMEI");
* System.getProperty("com.motorola.IMEI");
5. Siemens
* System.getProperty("com.siemens.IMEI");
6. LG
* System.getProperty("com.lge.imei");

In addition to this, there are some generic information about the device that can be retrieved by using System.getProperty(propertyString) method call, where value of propertyString can be vary as per your requirement. Few of them are listed as below:-

1. microedition.profiles
2. microedition.configuration
3. microedition.locale
4. microedition.platform

For more information see MIDP System Properties & J2ME Defined System Properties

Thursday, August 5, 2010

Call Javascript from a Java applet

Netscape only, using the javascript: protocol
A Javascript function is called from Java by using the showDocument method. A URL is needed with "javascript:" as the protocol.
[Java applet]
import java.applet.*;
import java.net.*;

public class InJava4 extends Applet{
  public void init(){
    String msg = "Hello from Java (using javascript alert)";
    try {
      getAppletContext().showDocument
        (new URL("javascript:doAlert(\"" + msg +"\")"));
      }
    catch (MalformedURLException me) { }
  }
}
[Javascript and HTML]


        NAME="myApplet"  MAYSCRIPT
        HEIGHT=10 WIDTH=10>
Try it here Netscape and IE ok, using the netscape.javascript.JSObject package
How to compile when using the netscape.javascript.JSObject package ?

For Java 1.4.2 and later: add plugin.jar to your classpath. It can be found in the lib directory of your JRE installation, e.g. C:\Program Files\Java\jre1.5.0\lib\plugin.jar
For Java 1.4.0/1.4.1: use jaws.jar (same directory).
In the following example, you type in the TextField a Javascript function and press the button to execute the function. For example, try alert('Hello from JAVA'). Or you can execute function defined on the same page as the Applet. The Applet must contains the MAYSCRIPT parameter to be able to use JSObject.
Netscape and IE Ok.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import netscape.javascript.*;

public class InJava5 extends Applet implements ActionListener {
  Button b;
  TextField t;

  public void init() {
     t = new TextField(20);
     add(t);
     b = new Button("execute Javascript");
     add(b);
     b.addActionListener(this);
     }

  public void actionPerformed(ActionEvent ae) {
     if (ae.getSource() == b) {
       JSObject win = (JSObject) JSObject.getWindow(this);
       win.eval(t.getText());
       }
     }
}
Try it here Another way is to use the Reflection API. That way you don't need to modify your CLASSPATH for compilation or even import the netscape.jsobject package.
// posted by C Werner on the realhowto list
import java.lang.reflect.*;
...
// Somewhere in the applet class ...
...
String jscmd = "window.close()";  /* JavaScript command */
String jsresult = null;
boolean success = false;
try {
  Method getw = null, eval = null;
  Object jswin = null;
  Class c =
    Class.forName("netscape.javascript.JSObject"); /* does it in IE too */
  Method ms[] = c.getMethods();
  for (int i = 0; i < ms.length; i++) {
      if (ms[i].getName().compareTo("getWindow") == 0)
         getw = ms[i];
      else if (ms[i].getName().compareTo("eval") == 0)
         eval = ms[i];
      }
  }
  Object a[] = new Object[1];
  a[0] = this;               /* this is the applet */
  jswin = getw.invoke(c, a); /* this yields the JSObject */
  a[0] = jscmd;
  Object result = eval.invoke(jswin, a);
  if (result instanceof String)
    jsresult = (String) result;
  else
    jsresult = result.toString();
  success = true;
  }

catch (InvocationTargetException ite) {
  jsresult = "" + ite.getTargetException();
  }
catch (Exception e) {
  jsresult = "" + e;
  }

if (success)
    System.out.println("eval succeeded, result is " + jsresult);
else
    System.out.println("eval failed with error " + jsresult);

3 easy steps to self-sign a Applet Jar file

From link .

1. keytool -genkey -keystore myKeyStore -alias me

2. keytool -selfcert -keystore myKeyStore -alias me

3. jarsigner -keystore myKeyStore jarfile.jar me

Monday, August 2, 2010

What Is - Appropriate version of the BlackBerry JDE


Description

When creating and building your application, it is important to choose the correct version of the BlackBerry JDE to make sure that the application is compatible with the target BlackBerry smartphones. Applications built in the BlackBerry JDE are forward-compatible with newer BlackBerry Device Software versions, but they are not backward-compatible with older versions.
For example, an application built in BlackBerry JDE 4.1 runs on a BlackBerry smartphones running BlackBerry® Device Software 4.1 and later. It does not run on a BlackBerry smartphones running BlackBerry Device Software 4.0. Thus, when building applications, you should use a BlackBerry JDE version that matches the lowest version of BlackBerry Device Software you want to support.
Note: To verify the version of BlackBerry Device Software installed on the BlackBerry smartphone, select Options > About.


Applications developed using the BlackBerry JDE are forward-compatible but not backward-compatible. In other words, an application developed with JDE 4.1 will run on BlackBerry devices with device software version 4.1 and later; however, they will not run on device software 4.0.

Wednesday, July 28, 2010

MC55

how to create a shortcut in program
Cut and paste the shortcut from that folder into the \Windows\Start Menu\Programs folder on your device. You can also then rename the shortcut if you want.

Monday, July 26, 2010

Java MIDP2.1和JAVA MIDP2.0的本质区别是什么啊?

MIDP 2.1 新特性

在经历了N长时间的等待之后,MIDP 2.1终于诞生并应用于实际的机型中,对于MIDP2.0的升级版本,我们没有看到太多的功能推进,而是看到了将MIDP2.0中的许多特性进行了强制化的规定,从而更加的标准性,在兼容MIDP2.0的同时,对于许多组件的规格和性能作出了明确的规定,只是我们最高兴看到的,尤其是对于Image的数个规定,让我们感到欣慰,因为对于不同的厂商,他们的手机对于图片等多媒体能力的支持是相差很大的,比如韩系的手机(三星,LG之流)对于多媒体的支持那不是一般的差,除了外形说的过去以外,我真的不知道韩系手机有什么过人之处,总体而言,韩系手机是标注的“金絮其外,败絮其中”,而且还买的贼TMD贵,坑害广大的勤劳的中国人们-_-!!! 

目前,支持MIDP 2.1的手机主要是Nokia的(不愧是老大级的人物啊~),机型是Nokia 5610 XpressMusic、Nokia 5310 XpressMusic、Nokia 6555、Nokia 7500 Prism 、Nokia 7900 Prism、Nokia 6267、Nokia 6500 classic、Nokia 6500 slide 相信这些手机我们都是能看得到的(不是行货就是水货),MIDP标准的统一之路又跨进了一步了,不过,在我看过MIDP3.0之后,我觉得如果说MIDP3.0将来能够以比较快的速度普及的话,那比然是J2ME的又一个春天。 

MIDP 2.1 新特性: 

1、 一个TextField或一个TextBox的最小尺寸(存储容量)不能少于1000个字符 

2、 LCDUI布局指令必须被遵循 

3、 LayoutManager.insert()方法的行为必须依照以下的描述:insert(Layer,int)
描述:
       Public void insert(javax.microedition.lcdui.game.Layer l,int index)
       插入一个新的Layer对象到LayoutManager在指定的索引值
描述:
       插入一个已经被添加到这个LayoutManager的Layer对象等于先使用LayoutManager.remove()方法删除它,再用insert()方法添加到特定的索引。在LayoutManager.remove()方法被调用前,抛出IndexOutOfBoundsException的情况被检查
参数:
       Layer l:被插入的Layer对象
       int Index:在被添加的新的Layer对象的索引值 

异常抛出:NullPointerException:如果Layer对象为null
       IndexOutOfBoundsException:如果索引值小于0。如果索引值大于已经被添加到LayoutManager中的Layer对象的数量且Layer对象不能被添加到这个LayoutManager中。如果索引值大于已经被添加到LayoutManager中的Layer对象的数量且Layer对象已经被添加到这个LayoutManager中 

4、 一个带有item Command对象且表示模式是Item.PLAIN的StringTtem对象必须总是被作为添加了Command对象且表示模式是Item.HYPERLINK的StringTtem对象的方式显示 

5、 许多的MIDP LUDUI图像组件能包含文本(换句话说,一个字母数字字符),那被显示给用户。这些组件的例子是List, TextBox , Alert , StringItem ,Form和Item。一个实现常常需要截断这些可见的文本因为不能适合被给的UI组件的指定空间。在这种情况下,一个实现必须使用一个适当的可视化指示(例如一个省略符号)来指示用户,文本被截断。实际的符号或被用来显示截断的文本的符号以来于当前设备选择的区域设置。然而,可视化指示应该和用在设备本地的UI的指示一致。 

6、 Canvas的触摸事件必须被支持,如果基础硬件支持这个特色。在这种情况下,Canvas.hasPointerEvents()方法应该总是返回true。 

7、 Canvas的触摸拖曳事件必须被支持,如果基础硬件支持这个特色。在这种情况下,Canvas.hasPointerEvents()方法应该总是返回true。 

8、 Canvas的重复事件必须被支持。在这种情况下,Canvas.hasRepeatEvents()方法应该总是返回true。 

9、 双缓冲图像必须被支持。在这种情况下,Canvas.isDoubleBuffered()方法应该总是返回true。 

10、 不同的文本输入模式的可用性(例如:预言输入和仅仅是数字的输入)应该和Java和本地的应用程序相一致。这意味着,例如,如果预言输入文本模式在本地应用程序中可用,那也应该在Java应用程序中可用。 

11、 Image对象的创建(不管格式)必须至少支持:尺寸等于(屏幕宽度)乘以(屏幕高度)乘以(以字节为单位的颜色深度)或262144比特(128×128×16比特=32KB),无论哪一个更大。注意,一个Image对象的内在表现应该保持至少每个象素16字节的颜色/透明度数据 

12、 每一个包括在字符串值的通过System.getProperty(“microedition.commports”)方法返回的串行端口名字必须可获取通过javax.microedition.io.CommConnection接口 

12、 在每个协议,AllowedSender域必须匹配适当的输入事件的地址域。地址域的使用和语法和语意以来于协议。然而,地址和过滤器必须被比较通过精确的字符串匹配,在那里,字符串被一个接着一个字符的比较,字符需要正确地匹配通过两个通配符 

13、 以下地网络通信协议必须被支持,提供了以下Java ME接口的实现:javax.microedition.io.SockerConnection , javax.microedition.io.SecureConnection, javax.microedition.io.HttpsConnection 

14、 javax.microedition.io.HttpsConnection和javax.microedition.io.SecureConnection必须支持SSLv3协议,其它的,例如TLS,WTLS也许被支持。 

15、 应用程序描述符应该包含MIDlet-Permissions 

16、 以下的JAD/manifest文件属性被定义来支持指定预期的运行时执行环境:Runtime-Execution-Environment:这是一个可选的属性,指出了应用程序必须的运行时执行环境。这个属性也许有值MIDP.CLDC.如果MIDlet suite不指定属性,隐含的默认值是MIDP.CLDC。当值是MIDP.CLDC,实现的行为必须坚持在以下显示的更多的细节描述。这个属性值的附加值被在将来定义。手机实现必须支持这个属性。当值是MIDP.CLDC,实现的行为必须坚持以下要求:1、支持API和API行为,以及基础虚拟机,必须顺从CLDC1.1规范。2、手机实现也许二选一地使用Java ME的CDC规范。然而,如果CDC被用作基础配置,运行在这个平台顶端的应用程序必须看见一个语义学和功能上等于CLDC1.1平台的环境。CDC特定的API或者CDC特定行为必须不能被暴露给应用程序或应用程序开发者。3、当一个应用程序定义了Runtime-Execution-Environment属性值,应用程序必须也定义一个CLDC平台在MicroEdition-Configuration属性值中。4、如果一个应用程序定义了不被实现支持的Runtime-Execution-Environment属性值或MicroEdition-Configuration属性值,应用程序不能被安装。所有的手机实现必须支持MIDP.CLDC值对于Runtime-Execution-Environment属性。 

17、 用户使用OTA下载安装之后,实现必须提示用户是否启动MIDlet 

18、 实现必须允许MIDlet创建最小为10个的线程 

19、 支持至少512个属性 

20、 支持MIDlet suite包含1到5个MIDlet 

21、 每个MIDlet suite的RMS至少保证64K的空间,在内存足够的情况下 

22、 每个MIDlet suite至少可以创建10个独立记录存储 

23、 MIDP的MMAPI的子集必须遵守MMAPI1.1或以后版本 

24、 MicroEdition.profiles系统属性不能包含相同profile的不同的版本 

25、 Image对象中ISO/IEC JPEG和JFIF被支持 

26、 支持载入深度为1、2、4、8、16和32位的PNG格式 

27、 TextBox和TextField的约束TextField.EMAILDDR和TextField.URL必须允许相同的字符被输入如同被允许输入在TextField.ANY约束下 

28、 适合的设备必须实现基于时间的推注册,如果没有其它的安全机制基于时间的推注册不需要被显式的用户的许可 
Nokia E62
http://www.forum.nokia.com/Devices/Device_specifications/E63/

Nokia E72
http://www.forum.nokia.com/Devices/Device_specifications/E72/

Sunday, July 25, 2010

如何在Java ME平台上获取手机串号

本文系转载,证实S40确实无法获得IMEI(没有签名,也没有保错,返回null),se测试可以,5800I可以(不用签名),WM暂时没有找到任何方法.

注意:在Java ME平台上获取手机串号,在某些手机中是可行的,但是某些手机中就是无法获取的。对于即便是可以获取串号的手机来说,也仅仅限于进行了签名的应用程序才可以获得手机串号。

在诺基亚手机中,我们可以这样获取手机串号: System.getProperty("com.nokia.mid.imei")

在Series60平台的手几种,这样的获取串号操作需要你的应用程序被认证为网络运营商信任的应用程序或者手机生产商信任的应用程序,并且只有在 Series40第三版功能包1之后的手机设备中才能够使用。 On Series 40 phones this requires that your midlet is signed to either operator or manufacturer domain, and this is only available Series 40 3rd Edition FP1 devices and newer.

在S60平台,有些S60第三版的手机已经实现了这样的功能,如E60,E61,E62,但是不包括3250和5500。对于S60平台,获取串号并不需要签名认证。

在西门子手机中,我们可以这样获取传号: System.getProperty("com.siemens.IMEI")

其他手机:
三星: System.getProperty("com.samsung.imei");
索尼爱立信: System.getProperty("com.sonyericsson.imei");
摩托罗拉: System.getProperty("IMEI" );
诺基亚: System.getProperty("phone.imei");
System.getProperty("com.nokia.IMEI");

Thursday, July 22, 2010

Setting http Proxy for Java Application

There are 2 main ways to set/configure http proxy in your java application.

* As a command line option when invoking the VM
* Using the System.setProperty(String, String) in your code

There are 3 properties you can set to specify the proxy that will be used by the http protocol handler:

* http.proxyHost: the host name of the proxy server
* http.proxyPort: the port number, the default value being 80
* http.nonProxyHosts: a list of hosts that should be reached directly, bypassing the proxy

Example of using command line option to set proxy configuration on java
java -Dhttp.proxyHost=webcache.mydomain.com -Dhttp.proxyPort=8080
-Dhttp.noProxyHosts=”localhost|host.mydomain.com” YourAppMainClass

Example of using code to configure proxy setting on java
//Set the http proxy to webcache.mydomain.com:8080
System.setProperty("http.proxyHost", "webcache.mydomain.com");
System.setPropery("http.proxyPort", "8080");
// Next connection will be through proxy.

There are other proxy settings that you can set as well such as https, ftp, socks.
More resources:
http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html

Tuesday, July 20, 2010

Reboot BlackBerry

ALT+Right SHIFT+DEL will perfrom a soft reset

Thursday, July 15, 2010

Top Ten Tomcat Configuration Tips

1. Configuring the Admin Web Application

Most commercial J2EE servers provide a fully functional administrative interface, and many of these are accessible as web applications. The Tomcat Admin application is on its way to becoming a full-blown Tomcat administration tool rivaling these commercial offerings. First included in Tomcat 4.1, Admin already provides control over contexts, data sources, and users and groups. You can also control resources such as initialization parameters, as well as users, groups, and roles in a variety of user databases. The list of capabilities will be expanded upon in future releases, but the present implementation has proven itself to be quite useful.

The Admin web application is defined in the auto-deployment file CATALINA_BASE/webapps/admin.xml.

You must edit this file to ensure that the path specified in the docBase attribute of the Context element is absolute; that is, the absolute path of CATALINA_HOME/server/webapps/admin. Alternatively, you could just remove the auto-deployment file and specify the Admin context manually in your server.xml file. On machines that will not be managed by this application, you should probably disable it altogether by simply removing CATALINA_BASE/webapps/admin.xml.

If you're using a UserDatabaseRealm (the default), you'll need to add a user and a role to the CATALINA_BASE/conf/tomcat-users.xml file. For now, just edit this file, and add a role named "admin" to your users database:



You must also have a user who is assigned to the "admin" role. Add a user line like this after the existing user entries (changing the password to something a bit more secure):



Once you've performed these steps and restarted Tomcat, visit the URL http://localhost:8080/admin, and you should see a login screen. The Admin application is built using container-managed security and the Jakarta Struts framework. Once you have logged in as a user assigned to the admin role, you will be able to use the Admin application to configure Tomcat.
2. Configuring the Manager Web Application

The Manager web application lets you perform simple management tasks on your web applications through a more simplified web user interface than that of the Admin web app.

The Manager web application is defined in the auto-deployment file CATALINA_BASE/webapps/manager.xml.

You must edit this file to ensure that the path specified in the docBase attribute of the Context element is absolute; that is, the absolute path of CATALINA_HOME/server/webapps/manager.

If you're using the default UserDatabaseRealm, you'll need to add a user and role to the CATALINA_BASE/conf/tomcat-users.xml file. For now, just edit this file, and add a role named "manager" to your users database:



You must also have a user who is assigned the "manager" role. Add a user line like this after the existing user entries (changing the password to something a bit more secure):



Then restart Tomcat and visit the URL http://localhost/manager/list to see the plain-text manager interface, or http://localhost/manager/html/list for the simple HTML manager interface. Either way, your Manager application should now be working.

The Manager application lets you install new web applications on a non-persistent basis, for testing. If we have a web application in /home/user/hello and want to test it by installing it under the URI /hello, we put "/hello" in the first text input field (for Path) and "file:/home/user/hello" in the second text input field (for Config URL).

The Manager also allows you to stop, reload, remove, or undeploy a web application. Stopping an application makes it unavailable until further notice, but of course it can then be restarted. Users attempting to access a stopped application will receive an error message, such as 503 - This application is not currently available.

Removing a web application removes it only from the running copy of Tomcat -- if it was started from the configuration files, it will reappear the next time you restart Tomcat (i.e., removal does not remove the web application's content from disk).
3. Deploying a Web Application

There are two ways of deploying a web application on the filesystem:

1. Copy your WAR file or your web application's directory (including all of its content) to the $CATALINA_BASE/webapps directory.

2. Create an XML fragment file with just the Context element for your web application, and place this XML file in $CATALINA_BASE/webapps. The web application itself can then be stored anywhere on your filesystem.

If you have a WAR file, you can deploy it by simply copying the WAR file into the directory CATALINA_BASE/webapps. The filename must end with an extension of ".war". Once Tomcat notices the file, it will (by default) unpack it into a subdirectory with the base name of the WAR file. It will then create a context in memory, just as though you had created one by editing Tomcat's server.xml file. However, any necessary defaults will be obtained from the DefaultContext element in Tomcat's server.xml file.

Another way to deploy a web app is by writing a Context XML fragment file and deploying it into the CATALINA_BASE/webapps directory. A context fragment is not a complete XML document, but just one Context element and any subelements that are appropriate for your web application. These files are like Context elements cut out of the server.xml file, hence the name "context fragment."

For example, if we wanted to deploy the WAR file MyWebApp.war along with a realm for accessing parts of that web application, we could use this fragment:







Put that in a file called "MyWebApp.xml," and copy it into your CATALINA_BASE/webapps directory.

These context fragments provide a convenient method of deploying web applications; you do not need to edit the server.xml file and, unless you have turned off the default liveDeploy feature, you don't have to restart Tomcat to install a new web application.
4. Configuring Virtual Hosts

The Host element normally needs modification only when you are setting up virtual hosts. Virtual hosting is a mechanism whereby one web server process can serve multiple domain names, giving each domain the appearance of having its own server. In fact, the majority of small business web sites are implemented as virtual hosts, due to the expense of connecting a computer directly to the Internet with sufficient bandwidth to provide reasonable response times and the stability of a permanent IP address.

Name-based virtual hosting is created on any web server by establishing an aliased IP address in the Domain Name Service (DNS) data and telling the web server to map all requests destined for the aliased address to a particular directory of web pages. Since this article is about Tomcat, we don't try to show all of the ways to set up DNS data on various operating systems. If you need help with this, please refer to DNS and Bind, by Paul Albitz and Cricket Liu (O'Reilly). For demonstration purposes, I'll use a static hosts file, since that's the easiest way to set up aliases for testing purposes.

To use virtual hosts in Tomcat, you just need to set up the DNS or hosts data for the host. For testing, making an IP alias for localhost is sufficient. You then need to add a few lines to the server.xml configuration file:

























Tomcat's server.xml file, as distributed, contains only one virtual host, but it is easy to add support for additional virtual hosts. The simplified version of the server.xml file in the previous example shows in bold the overall additional structure needed to add one virtual host. Each Host element must have one or more Context elements within it; one of these must be the default Context for this host, which is specified by having its relative path set to the empty string (for example, path="").
5. Configuring Basic Authentication

Container-managed authentication methods control how a user's credentials are verified when a web app's protected resource is accessed. When a web application uses basic authentication (BASIC in the web.xml file's auth-method element), Tomcat uses HTTP basic authentication to ask the web browser for a username and password whenever the browser requests a resource of that protected web application. With this authentication method, all passwords are sent across the network in base64-encoded text.

Note: using basic authentication is generally considered insecure because it does not strongly encrypt passwords, unless the site also uses HTTPS or some other form of encryption between the client and the server (for instance, a virtual private network). Without this extra encryption, network monitors can intercept (and misuse) users' passwords. But, if you're just starting to use Tomcat, or if you just want to test container-managed security with your web app, basic authentication is easy to set up and test. Just add and elements to your web app's web.xml file, and add the appropriate and elements to your CATALINA_BASE/conf/tomcat-users.xml file, restart Tomcat, and Tomcat takes care of the rest.

The example below shows a web.xml excerpt from a club membership web site with a members-only subdirectory that is protected using basic authentication. Note that this effectively takes the place of the Apache web server's .htaccess files.






Entire Application

/members/*


member




BASIC
My Club Members-only Area


6. Configuring Single Sign-On

Once you've set up your realm and method of authentication, you'll need to deal with the actual process of logging the user in. More often than not, logging into an application is a nuisance to an end user, and you will need to minimize the number of times they must authenticate. By default, each web application will ask the user to log in the first time the user requests a protected resource. This can seem like a hassle to your users if you run multiple web applications and each application asks the user to authenticate. Users cannot tell how many separate applications make up any single web site, so they won't know when they're making a request that crosses a context boundary, and will wonder why they're being repeatedly asked to log in.


The "single sign-on" feature of Tomcat 4 allows a user to authenticate only once to access all of the web applications loaded under a virtual host. To use this feature, you need only add a SingleSignOn Valve element at the host level. This looks like the following:




The Tomcat distribution's default server.xml contains a commented-out single sign-on Valve configuration example that you can uncomment and use. Then, any user who is considered valid in a context within the configured virtual host will be considered valid in all other contexts for that same host.

There are several important restrictions for using the single sign-on valve:

The valve must be configured and nested within the same Host element that the web applications (represented by Context elements) are nested within.

The Realm that contains the shared user information must be configured either at the level of the same Host or in an outer nesting.

The Realm cannot be overridden at the Context level.

The web applications that use single sign-on must use one of Tomcat's built-in authenticators (in the element of web.xml), rather than a custom authenticator. The built-in methods are basic, digest, form, and client-cert authentication.

If you're using single sign-on and wish to integrate another third-party web application into your web site, and the new web application uses only its own authentication code that doesn't use container-managed security, you're basically stuck. Your users will have to log in once for all of the web applications that use single sign-on, and then once again if they make a request to the new third-party web application. Of course, if you get the source and you're a developer, you could fix it, but that's probably not so easy to do.

The single sign-on valve requires the use of HTTP cookies.

7. Configuring Customized User Directories

Some sites like to allow individual users to publish a directory of web pages on the server. For example, a university department might want to give each student a public area, or an ISP might make some web space available on one of its servers to customers that don't have a virtually hosted web server. In such cases, it is typical to use the tilde character (~) plus the user's name as the virtual path of that user's web site:

http://www.cs.myuniversity.edu/~username
http://members.mybigisp.com/~username

Tomcat gives you two ways to map this on a per-host basis, using a couple of special Listener elements. The Listener's className attribute should be org.apache.catalina.startup.UserConfig, with the userClass attribute specifying one of several mapping classes. If your system runs Unix, has a standard /etc/passwd file that is readable by the account running Tomcat, and that file specifies users' home directories, use the PasswdUserDatabase mapping class:



Web files would need to be in directories such as /home/users/ian/public_html or /users/jbrittain/public_html. Of course, you can change public_html to be whatever subdirectory into which your users put their personal web pages.

In fact, the directories don't have to be inside of a user's home directory at all. If you don't have a password file but want to map from a user name to a subdirectory of a common parent directory such as /home, use the HomesUserDatabase class:



In this case, web files would be in directories such as /home/ian/public_html or /home/jasonb/public_html. This format is more useful on Windows, where you'd likely use a directory such as C:\home.

These Listener elements, if present, must be inside of a Host element, but not inside of a Context element, as they apply to the Host itself.
8. Using CGI Scripts with Tomcat

Tomcat is primarily meant to be a servlet/JSP container, but it has many capabilities rivalling a traditional web server. One of these is support for the Common Gateway Interface (CGI), which provides a means for running an external program in response to a browser request, typically to process a web-based form. CGI is called "common" because it can invoke programs in almost any programming or scripting language: Perl, Python, awk, Unix shell scripting, and even Java are all supported options. However, you probably wouldn't run a Java application as a CGI due to the start-up overhead; elimination of this overhead was what led to the original design of the servlet specification. Servlets are almost always more efficient than CGIs because you're not starting up a new operating-system-level process every time somebody clicks on a link or button.

Tomcat includes an optional CGI servlet that allows you to run legacy CGI scripts; the assumption is that most new back-end processing will be done by user-defined servlets and JSPs.

To enable Tomcat's CGI servlet, you must do the following:

Rename the file servlets-cgi.renametojar (found in CATALINA_HOME/server/lib/) to servlets-cgi.jar, so that the servlet that processes CGI scripts will be on Tomcat's CLASSPATH.

In Tomcat's CATALINA_BASE/conf/web.xml file, uncomment the definition of the servlet named cgi (this is around line 241 in the distribution).

Also in Tomcat's web.xml, uncomment the servlet mapping for the cgi servlet (around line 299 in the distributed file). Remember, this specifies the HTML links to the CGI script.

Either place the CGI scripts under the WEB-INF/cgi directory (remember that WEB-INF is a safe place to hide things that you don't want the user to be able to view, for security reasons), or place them in some other directory within your context and adjust the cgiPathPrefix initialization parameter of the CGIServlet to identify the directory containing the files. This specifies the actual location of the CGI scripts, which typically will not be the same as the URL in the previous step.

Restart Tomcat, and your CGI processing should now be operational.

The default directory for the servlet to locate the actual scripts is WEB-INF/cgi. As has been noted, the WEB-INF directory is protected against casual snooping from browsers, so this is a good place to put CGI scripts, which may contain passwords or other sensitive information. For compatibility with other servers, though, you may prefer to keep the scripts in the traditional directory, /cgi-bin, but be aware that files in this directory may be viewable by the curious web surfer. Also, on Unix, be sure that the CGI script files are executable by the user under which you are running Tomcat.
9. Changing Tomcat's JSP Compiler

In Tomcat 4.1 (and above, presumably), compilation of JSPs is performed by using the Ant program controller directly from within Tomcat. This sounds a bit strange, but it's part of what Ant was intended for; there is a documented API that lets developers use Ant without starting up a new JVM. This is one advantage of having Ant written in Java. Plus, it means you can now use any compiler supported by the javac task within Ant; these are listed in the javac page of the Apache Ant manual. It is easy to use because you need only an with a name of "compiler" and a value of one of the supported compiler names:



jsp

org.apache.jasper.servlet.JspServlet


logVerbosityLevel WARNING


compiler jikes

3


Of course, the given compiler must be installed on your system, and the CLASSPATH may need to be set, depending on which compiler you choose.
10. Restricting Access to Specific Hosts

Sometimes you'll only want to restrict access to Tomcat's web app to only specified host names or IP addresses. This way, only clients at those specified sites will be served content. Tomcat comes with two Valves that you can configure and use for this purpose: RemoteHostValve and RemoteAddrValve.

These Valves allow you to filter requests by host name or by IP address, and to allow or deny hosts that match, similar to the per-directory Allow/Deny directives in Apache httpd. If you run the Admin application, you might want to only allow access to it from localhost, as follows:






If no allow pattern is given, then patterns that match the deny attribute patterns will be rejected, and all others will be allowed. Similarly, if no deny pattern is given, patterns that match the allow attribute will be allowed, and all others will be denied.

Blog Archive