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);
Subscribe to:
Posts (Atom)