Thursday, 3 May 2012

How to change keyboard layout for login windows?

on Windows
-------------------------
set HKEY_USERS\.DEFAULT\Keyboard Layout\Preload to
409: US
809: UK

on RHEL
-------------------------
run setup to make the change
then reboot the machine

Wednesday, 11 April 2012

How to install OWB on Win7 (64bit)?

<1> download OWB2.0 from http://www.itdesign.de/en/support-downloads/downloads.html

<2> install JRE1.6 (32bit)

<3> install OWB2.0 using above JRE (Note: it doesn't work with 64bit JRE.)

Saturday, 17 March 2012

How to send scheduled JavaMail from EJB3?

Assuming GlassFish3.1.2 is your server.

<1> add a JavaMail session in the Admin Console with following settings:

JNDI Name: myJavaMailSession
Mail Host: 127.0.0.1
Default User: me
Default Sender Address: me@any.net

<2> create a timer bean with following content:

@Stateless
public class MyBean {

    @Resource(mappedName = "myJavaMailSession")
    private javax.mail.Session session;

    @Schedule(minute = "*", second = "*/10", hour = "*", persistent = false)
    public void myTimer() {
        email("she@any.net", "mySubject", "myText");
    }

    private void email(String recipient, String subject, String text) throws MessagingException {
        MimeMessage message = new MimeMessage(session);
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
        message.setSubject(subject);
        message.setText(text);
        Transport.send(message);
    }
}

<3> allow outbound mails as following if you use iptables:

-A OUTPUT -p tcp --dport 25 -j ACCEPT
-A INPUT -p tcp --sport 25 -m state --state ESTABLISHED,RELATED -j ACCEPT

Saturday, 18 February 2012

How to build JTrac from sources?

assuming jdk1.6.0 and Glassfish3.1.1 and NetBeans6.9.1 have been installed and your PC is online.

download JTrac2.1.0 source file jtrac-src-2.1.0.zip and unzip it;

open jtrac project within NetBeans;

delete jtrac project from NetBeans (don't delete it from disk);

re-open jtrac project within NetBeans;

resolve problem (most dependencies jars will be downloaded);

download following unresolved jars from website:
selenium-server-0.9.0.jar
selenium-java-client-driver-0.9.0.jar

manually install above artifscts in 'Test Libraries';

'Add Dependency'commons-logging into 'Libraries';
GroupId=commons-logging
ArtifactId=commons-logging
Version=1.0.3

excuting 'test' target should be fine now.

in the project property, add property 'maven.test.skip=true' to 'Run Project' action;

set GF3 as the server to run;

excuting 'test' target should be fine now.

Wednesday, 21 December 2011

Web scraping

a computer software technique of extracting information from websites.

HtmlUnit is a headless web browser written in Java.
Selenium is a portable software testing framework for web applications.
JWebUnit is a Java-based testing framework for web applications.

JWebUnit and HtmlUnit both stub the browser, whereas Selenium runs inside the browser.

CAPTCHA

"Completely Automated Public Turing test to tell Computers and Humans Apart"
In other words, a computer administers a test to determine if the subject is or is not human.

Saturday, 3 September 2011

如何运行Wicket示范程序?

安装JDK1.6, NetBeans6.9.1, GlassFish3.1.1, Maven2.2.1 (set it as the External Maven Home in NetBeans)

Wicket in Action
================
下载http://wicketinaction.googlecode.com/files/wicket-in-action-0.9-source.zip

解压wicket-in-action-0.9-source.zip (注意:路径中不得有空格)

在NetBeans中,打开该项目, 并为其选择GlassFish3服务器

'Clean and Build' (Maven 将下载有关的库并存放在\.m2\repository下)

如果报告jta-1.0.1B.jar缺失,可从http://download.java.net/maven/2/javax/transaction/jta/1.0.1B/下载后,在项目库里选择'Manual install artifact',将其安装在本地库里后,重新Build

运行

Enjoying Web Development with Wicket
====================================
下载http://agileskills2.org/EWDW/source.zip

解压source.zip (注意:路径中不得有空格)

在NetBeans中,逐个打开项目, 并为其选择GlassFish3服务器,同时在其pom.xml文件中<build>块内,添加如下内容:


                <sourceDirectory>src/main/java</sourceDirectory>
                <resources>
                        <resource>
                                <filtering>false</filtering>
                                <directory>src/main/java</directory>
                                <includes>
                                        <include>**</include>
                                </includes>
                                <excludes>
                                        <exclude>**/*.java</exclude>
                                </excludes>
                        </resource>
                </resources>


'Clean and Build' (Maven 将下载有关的库并存放在\.m2\repository下)

运行