Using Twitter

April 2nd, 2009

Finally, I am trying the twitter. :-)

  • Share/Bookmark

temperary fix of Fedora 10 x86_64 snmpd segment fault

December 3rd, 2008

Due to the problem of Fedora 10 ’s new rpm 4.6, the snmpd can not start with a segment fault error.You can temperary work around this by adding a line to /etc/sysconfig/snmpd

OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd.pid -a -I -hr_swinst"
  • Share/Bookmark

Java timezone problem with F7

June 14th, 2008

Under fedora 7, you might find an incorrect time problem for java log4j output. The reason should be F7 using America/New York as the timezone name for New York, which is invalid for Java (should be America/New_York, with the underline instead of space). A solution is using system-config-date tool change it to America/Toronto.

  • Share/Bookmark

Set static ip on Fedora 9

May 17th, 2008

disable “Network Manager” service, enable: “network” service. Then you can set the static ip by editing /etc/sysconfig/network-scripts/…

  • Share/Bookmark

Install an external jar into local Maven repository

May 4th, 2008

Sometimes, you project will have dependency on a jar which is not in official maven repository, and maybe it is propriety jar file which will never be part of maven repository. In this case, you have to put it to your local repository your self to solve the dependency.

There is a install plug in to do this job, which is something like:

mvn install:install-file -DgroupId=<your_group_name>  \
-DartifactId=<your_artifact_name>  \
-Dversion=<snapshot>  \
-Dfile=<path_to_your_jar_file>  \
-Dpackaging=jar \
-DgeneratePom=true

For example, you want to install the danga’s memcached client plugin, you can do:

mvn install:install-file -DgroupId=com.danga \
-DartifactId=memcached \
-Dversion=2.0.1 \
-Dfile=java_memcached-release_2.0.1.jar \
-Dpackaging=jar \
-DgeneratePom=true

This will add the memcache jar into your local Maven2 repository under groupId com.danga and artifactId memcached, you can then edit your pom.xml adding this dependency.

However, the maven eclipse can not recognize it since it always search from public repository.

  • Share/Bookmark

Maven Project Layout

May 3rd, 2008

src/main/java Application/Library sources
src/main/resources Application/Library resources
src/main/filters Resource filter files
src/main/assembly Assembly descriptors
src/main/config Configuration files
src/main/webapp Web application sources
src/test/java Test sources
src/test/resources Test resources
src/test/filters Test resource filter files
src/site Site
LICENSE.txt Project’s license
README.txt Project’s readme

  • Share/Bookmark

Maven release

May 3rd, 2008

You can use maven release plugin to make your release job much easier. it will automatically test build the project and run all unit test. After that, it will create a tag for you, and then update the current snapshot version to a newer one.

For using the release plugin, you will need to set up the scm info first:

<project>
...
<scm>
    <connection>...</connection>
    <developerConnection>...</developerConnection>
    <url>...</url>
</scm>

The ‘connection’ tag is for read only checkout, and ‘developerConnection’ is with commit permission.

The value of them will look like: ’scm:svn:http://….’, given you are using SVN/Webdav as your SCM system.

After that, you can use: ‘mvn release:prepare’ for preparing your release. And you can use ‘mvn release:perform’ for doing the release.

Please note that if you don’t have a repository set up, the release:perform will fail. That’s okay is you don’t really need to release it by repository. You can just delete those 2 generated release property file.

  • Share/Bookmark

How to indicate the java compiler version and target version

May 3rd, 2008

By default, the maven will use the compiler source check level to 1.3 and target version to 1.1 for maximum artifact compatibility. However, in most of your project, you don’t need such compatibility. In contrast, you will want to use more recently language features: like assertion, generic type of container, and so on. You can do that be indicate the compiler source and target requirement.

First, from Eclipse IDE, select “maven – add plugin”, add the maven-compiler-plugin, the lastest version should be 2.02. This will add some elements to you pom.xml like:

...
<build>
  <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.0.2</version>
      </plugin>
  </plugins>
</build>
...

you can add attibutes after version, like:

<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
    <source>1.6</source>
    <target>1.6</target>
</configuration>

This will set the source check and target check version to jre 6.0. You will notice that although sun has change this naming scheme from 1.x to x.0 from jre 5.0 on, but maven still using 1.x scheme.

  • Share/Bookmark

Use log4j-1.2.14 instead of 1.2.15 in Maven Project

May 3rd, 2008

log4j-1.2.15 has a dependency on sun-jms-1.1, which is broken in Maven repository.

  • Share/Bookmark

Get Maven project from svn to Eclipse

May 3rd, 2008

When you put a maven project under source control like SVN, you don’t have to check in the IDE’s project file. What you will do is check in the pom.xml and the source folder.  That is enough for you to rebuild the project.

If you want to continue work on this project on your favorite IDE (like Eclipse) again, you can simply choose “File-import” and from the dialog box, select “Other – Check out Maven Project from scm” and the locate you source repository in the following wizard, and you are good to go. The Maven plugin will generate the project file for you according to pom file settings.

  • Share/Bookmark