http://zhongzhao-2008.javaeye.com/blog/201487
http://hi.baidu.com/zhaolaiwei/blog/item/7e09e25866959884800a18d8.html
http://www.blogjava.net/rain1102/archive/2009/05/26/278023.html
9.12.09
8.12.09
Android & Web Services
http://www.slideshare.net/sullis/connecting-to-web-services-on-android
http://www.warriorpoint.com/blog/2009/07/19/android-reading-using-and-working-with-xml-data-and-web-services-in-android/
http://www.ibm.com/developerworks/opensource/library/x-android/index.html?ca=dgr-lnxw82Android-XML&S_TACT=105AGX59&S_CMP=grlnxw82
http://www.warriorpoint.com/blog/2009/07/19/android-reading-using-and-working-with-xml-data-and-web-services-in-android/
http://www.ibm.com/developerworks/opensource/library/x-android/index.html?ca=dgr-lnxw82Android-XML&S_TACT=105AGX59&S_CMP=grlnxw82
Labels:
android,
web services
7.12.09
Open Source Command Line Interpreters in Java
http://java-source.net/open-source/command-line
http://commons.apache.org/cli/
http://commons.apache.org/cli/
3.12.09
1.12.09
HOME key and Backspace key
http://www.cyberciti.biz/tips/freebsd-how-to-customized-home-del-insert-keys-for-bash-shell.html
http://www.ibb.net/~anne/keyboard.html
# the following line is actually
# equivalent to "\C-?": delete-char
"\e[3~": delete-char
# VT
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# kvt
"\e[H": beginning-of-line
"\e[F": end-of-line
# rxvt and konsole (i.e. the KDE-app...)
"\e[7~": beginning-of-line
"\e[8~": end-of-line
# VT220
"\eOH": beginning-of-line
"\eOF": end-of-line
http://www.ibb.net/~anne/keyboard.html
# the following line is actually
# equivalent to "\C-?": delete-char
"\e[3~": delete-char
# VT
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# kvt
"\e[H": beginning-of-line
"\e[F": end-of-line
# rxvt and konsole (i.e. the KDE-app...)
"\e[7~": beginning-of-line
"\e[8~": end-of-line
# VT220
"\eOH": beginning-of-line
"\eOF": end-of-line
Labels:
Linux
29.11.09
27.11.09
Remember the cursor when close the file in vim
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
Labels:
vim
Highlight after Search
set hlsearch
set nohlsearch
noh
set nohlsearch
noh
Labels:
vim
24.11.09
JavaCC
http://en.wikipedia.org/wiki/JavaCC
http://www.engr.mun.ca/~theo/JavaCC-Tutorial/
http://www.engr.mun.ca/~theo/JavaCC-FAQ/
JavaCC (Java Compiler Compiler) is an open source parser generator for the Java programming language. JavaCC is similar to Yacc in that it generates a parser for a formal grammar provided in EBNF notation, except the output is Java source code. Unlike Yacc, however, JavaCC generates top-down parsers, which limits it to the LL(k) class of grammars (in particular, left recursion cannot be used). The tree builder that accompanies it, JJTree, constructs its trees from the bottom up.
JavaCC is licensed under a BSD license.
http://www.engr.mun.ca/~theo/JavaCC-Tutorial/
http://www.engr.mun.ca/~theo/JavaCC-FAQ/
JavaCC (Java Compiler Compiler) is an open source parser generator for the Java programming language. JavaCC is similar to Yacc in that it generates a parser for a formal grammar provided in EBNF notation, except the output is Java source code. Unlike Yacc, however, JavaCC generates top-down parsers, which limits it to the LL(k) class of grammars (in particular, left recursion cannot be used). The tree builder that accompanies it, JJTree, constructs its trees from the bottom up.
JavaCC is licensed under a BSD license.
Oh Come on, Sun..... Oh, Oracle now. PID things
http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html
20.11.09
Post Source Code on Blogger
Template:
<!-- synthax highlighter -->
<link href='http://bcardoso.planetaclix.pt/blog/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://bcardoso.planetaclix.pt/blog/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://bcardoso.planetaclix.pt/blog/js/shCore.js' type='text/javascript'></script>
<script src='http://bcardoso.planetaclix.pt/blog/js/shBrushJScript.js' type='text/javascript'></script>
<script src='http://bcardoso.planetaclix.pt/blog/js/shBrushJava.js' type='text/javascript'></script>
<script src='http://bcardoso.planetaclix.pt/blog/js/shBrushCss.js' type='text/javascript'></script>
<script src='http://bcardoso.planetaclix.pt/blog/js/shBrushJScript.js' type='text/javascript'></script>
<script src='http://bcardoso.planetaclix.pt/blog/js/shBrushPlain.js' type='text/javascript'></script>
<script src='http://bcardoso.planetaclix.pt/blog/js/shBrushSql.js' type='text/javascript'></script>
<script src='http://bcardoso.planetaclix.pt/blog/js/shBrushXml.js' type='text/javascript'></script>
<script type='text/javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.tagName = 'pre';
SyntaxHighlighter.all();
</script>
<!-- synthax highlighter -->
Blog Article:
<pre class="brush:java">
You Java Source Code Here
</pre>
A Simple DES Encrypting/Decrypting Sample
public class TestCrypto {
public static void main(String [] args) throws Exception{
SecureRandom sr = new SecureRandom();
KeyGenerator kg = KeyGenerator.getInstance("DES");
kg.init(sr);
SecretKey key = kg.generateKey();
byte rawKeyData[] = key.getEncoded();
System.out.println("Secret Key => " + Arrays.toString(rawKeyData));
String str = "hello world";
DESKeySpec dks = new DESKeySpec(rawKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key2 = keyFactory.generateSecret(dks);
Cipher ci = Cipher.getInstance("DES");
ci.init(Cipher.ENCRYPT_MODE, key, sr);
byte data[] = str.getBytes();
byte[] encryptedData = ci.doFinal(data);
ci = Cipher.getInstance("DES");
ci.init(Cipher.DECRYPT_MODE, key, sr);
byte[] decryptedData = ci.doFinal(encryptedData);
System.out.println("Decrypted => " + new String(decryptedData));
}
}
19.11.09
Document for XJC
http://www.j2ee.me/webservices/docs/2.0/jaxb/xjc.html
The one from JDK documentations
Java/jdk-6u10-docs/docs/technotes/tools/share/xjc.html
A Simple Configuration Manager Architecture
This is a simple configuration architecture I use for my small applications these days. I'm happy with it now.
I have
- A Singleton Application Manager, which represent the business layer of my application information.
- Configuration Manager is also a Singleton class, but not necessary to be Singleton. Application Manager is the only class which would have relationship with Configuration Manager. The later one is a reusable class, providing DAO implementations to XML based Properties accessing to configuration files.
- Configuration items are represented by POJO/JavaBeans, provided annotation on each field.
- Application Manager parses the configuration POJO and retrieve configuration items via Configuration Manager, and saves the POJO as configuration items via Configuration Manager.
Something more:
- A DAO layer.
- Spring
- Apache Configuration
NetBeans JAXB Problem: typedef class com.sun.tools.xjc.XJCTask cannot be found
Phenomenon:
I developed a JAXB application using JAXB Wizard on Netbeans 6.7.1. I submitted the program to SVN and then checkout into another computer. When I tried to compile the program, I met an error as:
D:\......\xml_binding_build.xml:8: typedef class com.sun.tools.xjc.XJCTask cannot be found
Reason:
Netbeans projects uses nbproject/private directory to contain some system dependent attributes. I usual ignore this directory when I submit my application to a version control system. However, Netbeans puts the JAXB path information in this directory, which cause my the compilation problem.
jaxws.endorsed.dir=D:\\Program Files\\NetBeans 6.7.1\\java2\\modules\\ext\\jaxws21\\api:D:\\Program Files\\NetBeans 6.7.1\\ide11\\modules\\ext\\jaxb\\api
Due to my understanding, I think this must be a bug of JAXB Wizard in Netbeans.
Solution:
Create another project in the current Netbeans environment and run JAXB Wizard once. Look at the nbproject/private/private.properties file, copy the corresponding line into your target JAXB application, clean and build the application.
I developed a JAXB application using JAXB Wizard on Netbeans 6.7.1. I submitted the program to SVN and then checkout into another computer. When I tried to compile the program, I met an error as:
D:\......\xml_binding_build.xml:8: typedef class com.sun.tools.xjc.XJCTask cannot be found
Reason:
Netbeans projects uses nbproject/private directory to contain some system dependent attributes. I usual ignore this directory when I submit my application to a version control system. However, Netbeans puts the JAXB path information in this directory, which cause my the compilation problem.
jaxws.endorsed.dir=D:\\Program Files\\NetBeans 6.7.1\\java2\\modules\\ext\\jaxws21\\api:D:\\Program Files\\NetBeans 6.7.1\\ide11\\modules\\ext\\jaxb\\api
Due to my understanding, I think this must be a bug of JAXB Wizard in Netbeans.
Solution:
Create another project in the current Netbeans environment and run JAXB Wizard once. Look at the nbproject/private/private.properties file, copy the corresponding line into your target JAXB application, clean and build the application.
9.11.09
Select a directory with a JFileChooser
reference: http://www.rgagnon.com/javadetails/java-0370.html
chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle(choosertitle);
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle(choosertitle);
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
8.10.09
Resource for Creating Java Based Server
Apache MINA: http://mina.apache.org
JBoss Netty: http://jboss.org/netty/
STOMP: http://stomp.codehaus.org/
JBoss Netty: http://jboss.org/netty/
STOMP: http://stomp.codehaus.org/
13.9.09
MX4J Step by Step: 2. Using mx4j
MX4J Step by Step: 1. A Simple MBean
http://java.sun.com/j2se/1.5.0/docs/guide/jmx/tutorial/essential.html
Notes:
You'd better use ObjectName.getInstance(String) instead of new ObjectName(String) for efficiency reason.
Notes:
You'd better use ObjectName.getInstance(String) instead of new ObjectName(String) for efficiency reason.
9.9.09
Import Project into Subversion Using NetBeans IDE
http://www.netbeans.org/kb/docs/ide/subversion.html#synchronizing
Here is some complementary:
1. on the server side:
svn mkdir ${repo-root}/<your-project-directory>/<your-project-directory>
2. on the client side:
svn://<host>/<repo-root>/<your-project-directory>/<your-project-directory>
If you don't create at lease one level of subdirectory and import the project under that subdirectory, you will encounter such an Error Message on the client side:
Trying to use the Subversion plugin with svn+ssh, I get the following: org.tigris.subversion.javahl.ClientException: Trying to use an unsupported feature Server d
1.9.09
Create an All-in-One Document Page of Javadoc
Today I was asked to print out all information of a Java project. I gave a solution based on Javadoc. However, Javadoc generates many HTML files for packages and classes, one for each generally. I came up with an idea to re-organise all the files together.
Therefore, I made a PERL program to do the job automatically. I found Javadoc has very good documentation templates, all essential information comes between
<!-- ========= END OF TOP NAVBAR ========= -->
and
<!-- ======= START OF BOTTOM NAVBAR ====== -->
This template helps me a lot. The work ended up with a 200 lines of PERL.
Actually, I could refine the document a little bit. But the current solution is good enough I think.
31.8.09
JavaDB/Derby: Worthy to Have a Try!
Originally, I was looking for an embedded Java database. JavaDB could work in an embedded style, but with 2M limitation. That's terrible. However, since I can control JavaDB server within my Java application, I run the server with a random server port, then connect to it within the same program. Now, my database looks like an embedded one but with no limitation on size. Additionally, JavaDB is much more faster than SQLite3.
30.8.09
27.8.09
Embedded DB within Java using Derby/JavaDB
Reference: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javadb/
1. Download JavaDB from
http://developers.sun.com/prodtech/javadb/downloads/
or Apache Derby site.
2. Copy derby.jar to your runtime environment
3. Create a JDBC connection to an embedded Derby DB using code similar to the following:
String dbName = "testDb";
Properties props = new Properties();
props.put("user", "testuser");
props.put("password", "testpass");
conn = DriverManager.getConnection("jdbc:derby:" + dbName
+ ";create=true", props);
Note that within Java 6/JDBC 4, you don't need to call Class.forName() explicitly to load the JDBC driver.
4. Nothing else. Enjoy it!
Labels:
Derby,
Embedded DB,
JavaDB,
JDBC 4
The new created file permission within cygwin is always wrong!
It's always being 000.... I still don't know what happen with my cygwin. I checked unmask, and found it was set properly as 022. What's wrong?
24.8.09
Domain User to Use Cygwin
It's the first time I encounter this.
When I started the bash shell for cygwin in my office using my Laptop, I found some extra message that telling me that the passwd/group file should be rebuilt using mkpasswd -l and mkgroup -l. I tried it but the same message show again. Finally I found there should be a -d parameter there because I'm a domain user in my Office. So I did, and everything works fine.
Installing NetBean 6.7.1
Costs me lots of time.
So I install cygwin at the same time.
Do some testing for Apache ant regarding Jar merging.
Integrating Mantis and Subversion
http://alt-tag.com/blog/archives/2006/11/integrating-mantis-and-subversion/
1. add configuration items into mantis's config_inc.php
2. create post-commit script for the designated svn repository.
Note that there are some problem within alt-tag.com's script file, please
refer to http://www.svnforum.org/2017/viewtopic.php?t=6656 for a solution.
23.8.09
SVN repo creation
http://subversion.tigris.org/faq.html#repository
Solution 1.
Create a common repository and use svn mkdir to create subdirectories for
different projects.
$svnadmin create /repo/svn
$svn mkdir file:///repo/svn/projA
$svn mkdir file:///repo/svn/projB
$svn mkdir file:///repo/svn/projC
Solution 2.
Create a normal directory, and create managed subdirectories for projects.
$mkdir /repo/svn
$svnadmin create /repo/svn/projA
$svnadmin create /repo/svn/projB
$svnadmin create /repo/svn/projC
These two solutions look like simliar. However, for the first one,
when projC change, the revision number changes in other two projects.
Labels:
svn
6.6.09
AAWC Auburn Asian Welfare Centre - Design
Auburn Asian Welfare Centre (AAWC), http://www.aawcentre.org.au, asked me to design and develop a new website for them. I'm very happy to do that, for I know AAWC is a centre try to help Asian migrants and international students with pychological problems and gambling problems. I believe a better website could help their potential clients find the proper services.
My work began from their original website. Unfortunately, I could hardly get any theme idea from this website, therefore I have to design a new one from the very beginning. Now I finished the first design. Green is the theme colour of the Centre, so it was chosen here as the theme colour. The logo on the left top corner was a modified version of the one on the Centre's business card.
25.2.09
Static Analysis Tools for C
From coder@slug
coverity - commercial
flexelint - commercial
splint http://www.splint.org/
CIL http://hal.cs.berkeley.edu/cil/ http://sourceforge.net/projects/cil http://et.redhat.com/~rjones/cil-analysis-of-libvirt/
sloccount - lines of code analysis only
24.2.09
Do the Right Things & Do the Thing Right
Analysis = Do the right thing
Design = Do the thing right
Object-oriented analysis: there is an emphasis on finding and describing the objects and concepts in the problem domain.
Object-oriented design: there is an emphasis on defining software objects and how they collaborate to fulfill the requirements.
OOA -> OBJECTS and CONCEPTS (in problem domain)
OOD -> SOFTWARE OBJECTS and COLLABORATION (in software domain)
Further more:
Object-oriented analysis is concerned with creating a description of the domain from the perspective of objects. There is an identification of the concepts, attributes, and associations that are considered noteworthy. -> domain model -> domain model is not a description of software objects; it is a visualization of the concepts or mental models of a real-world domain. -> conceptual object model.
OOA -> domain model / conceptual object model -> concepts/objects, attributes, associations
Object-oriented design is concerned with defining software objects, their responsibilities and collaborations. A common notation to illustrate these collaborations is the sequence diagram.
OOD -> sequence diagram (or others) -> software objects, objects' responsibilities and collaborations.
Design = Do the thing right
Object-oriented analysis: there is an emphasis on finding and describing the objects and concepts in the problem domain.
Object-oriented design: there is an emphasis on defining software objects and how they collaborate to fulfill the requirements.
OOA -> OBJECTS and CONCEPTS (in problem domain)
OOD -> SOFTWARE OBJECTS and COLLABORATION (in software domain)
Further more:
Object-oriented analysis is concerned with creating a description of the domain from the perspective of objects. There is an identification of the concepts, attributes, and associations that are considered noteworthy. -> domain model -> domain model is not a description of software objects; it is a visualization of the concepts or mental models of a real-world domain. -> conceptual object model.
OOA -> domain model / conceptual object model -> concepts/objects, attributes, associations
Object-oriented design is concerned with defining software objects, their responsibilities and collaborations. A common notation to illustrate these collaborations is the sequence diagram.
OOD -> sequence diagram (or others) -> software objects, objects' responsibilities and collaborations.
Use Case
User Cases are not an object-oriented artifact. They are simply written stories.
---- Applying UML and Patterns
Requirements analysis may include stories and scenarios of how people use the application; these can be written as USE CASES.
USE CASES == STORIES
---- Applying UML and Patterns
Requirements analysis may include stories and scenarios of how people use the application; these can be written as USE CASES.
USE CASES == STORIES
17.2.09
Java's Bitwise Operators
Some notes on Java's bitwise operators, answering a question from one of my friend:
1. There are only three bitwise shift operators, <<, >>, and >>>. Remember there is no <<<
2. << and >> move only the bits other than the sign bit.
3. >>> works the way as >> does, except that the former one uses the sign bit as the top bit. Please try -1 >>> 1 to see what will happen.
4. When applying bitwise shift operators on negative integers, make sure you have translated the BITs into binary expression. Don't simply shift the bits as if you work on a positive value.
13.2.09
New Life Here!
Sydney, I'm here now! In fact, I've been in Sydney for about one and a half month. So far so good.
Early last month I enrolled myself in the NSW AMES, taking a full-time course named SkillMax. The course will last as long as ten weeks, concerning Australia culture, professional environment, and job seeking techniques.
Early this month, I went to TAFE and enrolled another full-time course, Software Programming. This is a professional course, teaching Java, VB.net, Software Analaysis and Design, Web Technology and Project Management. Although with more than 9 years of experience in software development using C, C++ and Java, I still get benefits from the course, improving my verbal skills, learning jargons, and update my knowledge.
People in NSW AMES and TAFE are nice, including college staffs and classmates. So I make many new friends. Thank you guys! I love you all!
Subscribe to:
Posts (Atom)