Thursday, December 31, 2009
VMWare v.s. VirtualBox
目前大概使用的方式上分為兩種
1. 若這一台 VM 是共用的,個人認為使用 VMWare 比較方便,由其是 VMWare Server 版,目前已經可以透過 Web 去控制 VM 的內容,也可以利用 IE 或 Firefox 的 Plugin 去遠端遙控實體 VM,實在非常方便。
但是若裝在個人使用的 PC 或 Notebook 上,那就不太方便。因為得啟動好幾個 service 才能啟動 VM,但並不是每天都會用到 VM,所以平常要用時再去啟動這些 service 比較不會浪費記憶體。但使用頻繁時又得手動去啟動這些 Service ,真的是不方便
2. 若這些 VM 是自己測試用的且裝在自己的機器上,那建議用 Virtual Box ,因為快速,簡便,不佔記憶體,比 VMWare 在操作上便利許多。目前還支援 snapshot 的功能,可以測試完後馬上還原成原始狀態,方便許多。尤其有時候要下載一些軟體又怕此軟體有木馬時,可以用這種方式先檢驗此軟體是否有破壞性。執行完此軟體時若系統遭破壞,可以利用 snapshot 的功能馬上恢復系統,不用再重新灌系統,實在方便許多
這裡並不是評估哪一個 VM software 比較好,而是就效益上再不同場合有不同的利用方式,可以達到最有效果的功能,這樣做事的效率才是最高的
Tuesday, December 8, 2009
Sunday, November 1, 2009
Upgrade Ubuntu 9.10,結果中文輸入法會掛
這是怎麼回事呢,得好好查查看
PS:查過 forum 後,發現是 bug ,尤其是從 pgdign 匯入帳號比較會發生此情況。問題已經提到 Ubuntu 的清單上,只是尚未有結果。
Monday, October 26, 2009
如何解決 jQuery 與 Prototype 的衝突
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery.noConflict()
</script>
<script src="prototype.js" type="text/javascript"></script>
Android 2.0
哇靠,SDK 都才 1.6 ,Motorola 竟然已經跑到 2.0 的版本了
話說去年 8 月發表 1.0 時,就想試試看,但因為工作關係,一直沒機會朝這方面發展,但一下子,已到了百發齊放的地步了。一堆 Android 機漸漸出籠,Windows Mobile 與 iPhone 必須小心 Android 的發展,畢竟有 Google 這家老店把關,系統上不會差到哪邊去,而且會越來越強
找時間試試看寫一個應用程式,畢竟 Java 摸了 10 幾年,應該試試看這個新玩意
Saturday, October 24, 2009
Virtual Box 3.0.8
最近聽說 VM Player 出 3.0 版,可以 create vm。有了這個功能,就不用再安裝 Server 版,因為 Server 版實在 loading 太重了。若是在 notebook 要跑 VM ,建議用 Virtual Box 或 VM Player. 若有 PC 或 Server 可以用的話,倒是可以裝 VMWare Server ,因為可以用 Service 跑,啟動時會順便把 VM 啟動,對 Web server 與 DB 是比較好的方式
Virtual Box 可以在以下 download
http://www.virtualbox.org/
VM Player 可以在以下 download
http://downloads.vmware.com/d/
PS : 官方目前只有 2.5 版, 3.0 版可能還要等一下
Thursday, August 27, 2009
Subversion 的 trunk, branches 與 tags (part 1)
這次來談談如何做 branches 與 tags ,並且如何做 merge 的動作
(待續 ....)
Wednesday, August 26, 2009
解決 Ubuntu 的 flash 的中文亂碼
1. gedit /etc/fonts/conf.d/49-sansserif.conf
2. change "sans-serif" to "sans serif" and save.
3. restart firefox.
That should works great.
Monday, June 29, 2009
Sunday, June 7, 2009
解決 AppFuse 2.0.2 的 menu 會消失的問題
將 styles/simplicity/nav-horizontal.css 的
ul#primary-nav ul {
position: absolute;
display: none;
left: 0px; /* Set 1px less than menu width */
top: 22px;
}
改成
ul#primary-nav ul {
position: absolute;
display: none;
left: 0px; /* Set 1px less than menu width */
top: 21px;
}
Submenu 便不會消失了。這個應該要 check 到 AppFuse 的 release 才對
看來只能等 Appfuse 2.1 才會改了
Saturday, May 16, 2009
將 Ubuntu 9.04 的字體變清楚
Ubuntu 的中文字型做了 antialias 導致中文字型都會有毛邊。
經 google 後, 發現可以用以下方式修改,將毛邊去掉
1.打開終端機
~$ sudo gedit /etc/fonts/conf.avail/66-wqy-zenhei-sharp.conf
將
改為
將
改為
存檔離開
2.在終端機輸入
~$ sudo ln -s /etc/fonts/conf.avail/66-wqy-zenhei-sharp.conf /etc/fonts/conf.d
如此便可以去掉毛邊,比較清析
Sunday, May 10, 2009
在 Netbeans 下安裝 Android 1.5 R1 SDK
1. 先下載 Android SDK 1.5 R1 ,然後解壓縮到 d:\java
2. 複製 D:\java\android-sdk-windows-1.5_r1\platforms\android-1.5\ 的內容到 D:\java\android-sdk-windows-1.5_r1 ,因為 1.5 的 Layout 已經修改,在 plugin 尚未出新版前,只能先以這種方式解決。
3. 執行以下命令建立新的模擬器
d:\>cd D:\java\android-sdk-windows-1.5_r1\tools
d:\>android create avd -n avd_1.5_1 -t 2
這個會建立一個模擬器叫做 avd_1.5_1 ,target 為 2 (2 是 1.5 版的代號)
4. 加入 Android 1.5 版到 NetBeans 中
4.1 打開 Tools > Java Platforms > Android
4.2 按 "Add Platform"
4.3 選擇 Google Android Open Handheld Platform
4.4 指定 SDK 1.5 的目錄
4.5 在指定 Platform 的 Name, 便可以建立 Android 1.5 的 platform.
5. 更改 android 的 project file "buld.xml"
打開之前的 HelloWorld project 在 build.xml 中加入以下內容 <> 用 [] 取代
[target name="-pre-init"]
[property name="emulator.options" value="-avd avd_1.5_1"/]
[/target]
6. 重新 build 並 run 便可以執行此專案了.
後記 : 目前 Android 還是只支援 Eclipse. 至於是否會支援 NetBeans ,變數可能加大,因為 Oracle 將 Sun 買下來後,是否會放棄 NetBeans,還是未知數。
Monday, April 20, 2009
Oracle acquire Sun
人生就是這樣,起起落落,誰都不能確定下一步會變成什麼樣。
今天是很成功的人,下一秒有可能淪落。
誰能預料,也許 Microsoft 會被 Google 買走也不一定啊!!
還是腳踏實地的做事,別好高鶩遠了
Saturday, April 11, 2009
jQuery plugin 大集合
以下是幾個 jQuery 的 plugin, 節錄自 http://www.wowbox.com.tw/blog/article.asp?id=3250
若需要更新,請自行去此網站取得
最近試用了 jQuery lightBox plugin ,讚!!
File upload-文件上傳
Ajax File Upload
jQUploader
Multiple File Upload plugin
jQuery File Style
Styling an input type file
Progress Bar Plugin
Form Validation-表單驗證
jQuery Validation
Auto Help
Simple jQuery form validation
jQuery XAV - form validations
jQuery AlphaNumeric
Masked Input
TypeWatch Plugin
Text limiter for form fields
Ajax Username Check with jQuery
Form - Select Box stuff-表單-選取框
jQuery Combobox
jQuery controlled dependent (or Cascadign) Select List
Multiple Selects
Select box manipulation
Select Combo Plugin
jQuery - LinkedSelect
Auto-populate multiple select boxes
Choose Plugin (Select Replacement)
Form Basics, Input Fields, Checkboxes etc.-表單的基本輸入框,選擇框等
jQuery Form Plugin
jQuery-Form
jLook Nice Forms
jNice
Ping Plugin
Toggle Form Text
ToggleVal
jQuery Field Plugin
jQuery Form’n Field plugin
jQuery Checkbox manipulation
jTagging
jQuery labelcheck
Overlabel
3 state radio buttons
ShiftCheckbox jQuery Plugin
Watermark Input
jQuery Checkbox (checkboxes with imags)
jQuery SpinButton Control
jQuery Ajax Form Builder
jQuery Focus Fields
jQuery Time Entry
Time, Date and Color Picker-時間、日期和顏色選取
jQuery UI Datepicker
jQuery date picker plugin
jQuery Time Picker
Time Picker
ClickPick
TimePicker
Farbtastic jQuery Color Picker Plugin
Color Picker by intelliance.fr
Rating Plugins-投票插件
jQuery Star Rating Plugin
jQuery Star Rater
Content rater with asp.net, ajax and jQuery
Half-Star Rating Plugin
Search Plugins-搜索插件
jQuery Suggest
jQuery Autocomplete
jQuery Autocomplete Mod
jQuery Autocomplete by AjaxDaddy
jQuery Autocomplete Plugin with HTML formatting
jQuery Autocompleter
AutoCompleter (Tutorial with PHP&MySQL)
quick Search jQuery Plugin
Inline Edit & Editors-嵌入的編輯器,所見即所得的編輯器
jTagEditor
WYMeditor
jQuery jFrame
Jeditable - edit in place plugin for jQuery
jQuery editable
jQuery Disable Text Select Plugin
Edit in Place with Ajax using jQuery
jQuery Plugin - Another In-Place Editor
TableEditor
tEditable - in place table editing for jQuery
Audio, Video, Flash, SVG, etc-音頻,視頻,flash,svg等
jMedia - accessible multi-media embedding
JBEdit - Ajax online Video Editor
jQuery MP3 Plugin
jQuery Media Plugin
jQuery Flash Plugin
Embed QuickTime
SVG Integration
jQuery Multimedia Portfolio
jQuery YouTube Plugin
Photos/Images/Galleries-照片,圖像,相冊等
ThickBox
jQuery lightBox plugin
jQuery Multimedia Portfolio
jQuery Image Strip
jQuery slideViewer
jQuery jqGalScroll 2.0
jQuery - jqGalViewII
jQuery - jqGalViewIII
jQuery Photo Slider
jQuery Thumbs - easily create thumbnails
jQuery jQIR Image Replacement
jCarousel Lite
jQPanView
jCarousel
Interface Imagebox
Image Gallery using jQuery, Interface & Reflactions
simple jQuery Gallery
jQuery Gallery Module
EO Gallery
jQuery ScrollShow
jQuery Cycle Plugin
jQuery Flickr
jQuery Lazy Load Images Plugin
Zoomi - Zoomable Thumbnails
jQuery Crop - crop any image on the fly
Image Reflection
Google Map-google地圖
jQuery Plugin googlemaps
jMaps jQuery Maps Framework
jQmaps
jQuery & Google Maps
jQuery Maps Interface forr Google and Yahoo maps
jQuery J Maps - by Tane Piper
Games-遊戲
Tetris with jQuery
jQuery Chess
Mad Libs Word Game
jQuery Puzzle
jQuery Solar System (not a game but awesome jQuery Stuff)
Tables, Grids etc.-表格,格子等
UI/Tablesorter
jQuery ingrid
jQuery Grid Plugin
Table Filter - awesome!
TableEditor
jQuery Tree Tables
Expandable “Detail” Table Rows
Sortable Table ColdFusion Costum Tag with jQuery UI
jQuery Bubble
TableSorter
Scrollable HTML Table
jQuery column Manager Plugin
jQuery tableHover Plugin
jQuery columnHover Plugin
jQuery Grid
TableSorter plugin for jQuery
tEditable - in place table editing for jQuery
jQuery charToTable Plugin
jQuery Grid Column Sizing
jQuery Grid Row Sizing
Charts, Presentation etc.-圖表
Flot
jQuery Wizard Plugin
jQuery Chart Plugin
Bar Chart
Border, Corners, Background-邊,角,背景
jQuery Corner
jQuery Curvy Corner
Nifty jQuery Corner
Transparent Corners
jQuery Corner Gallery
Gradient Plugin
Text and Links-文本和鏈接
jQuery Spoiler plugin
Text Highlighting
Disable Text Select Plugin
jQuery Newsticker
Auto line-height Plugin
Textgrad - a text gradient plugin
LinkLook - a link thumbnail preview
pager jQuery Plugin
shortKeys jQuery Plugin
jQuery Biggerlink
jQuery Ajax Link Checker
Chili jQuery code highlighter plugin
jScroller
Tooltips-提示
jQuery Plugin - Tooltip
jTip - The jQuery Tool Tip
clueTip
BetterTip
Flash Tooltips using jQuery
ToolTip
Menus, Navigations-菜單,導航
jQuery Tabs Plugin - awesome! [ demo nested tabs ]
another jQuery nested Tab Set example (based on jQuery Tabs Plugin)
jQuery idTabs
jdMenu - Hierarchical Menu Plugin for jQuery
jQuery SuckerFish Style
jQuery Plugin Treeview
treeView Basic
FastFind Menu
Sliding Menu
Lava Lamp jQuery Menu
jQuery iconDock
jVariations Control Panel
ContextMenu plugin
clickMenu
CSS Dock Menu
jQuery Pop-up Menu Tutorial
Sliding Menu
Accordions, Slide and Toggle stuff-幻燈、翻轉
jQuery Plugin Accordion
jQuery Accordion Plugin Horizontal Way
haccordion - a simple horizontal accordion plugin for jQuery
Horizontal Accordion by portalzine.de
HoverAccordion
Accordion Example from fmarcia.info
jQuery Accordion Example
jQuery Demo - Expandable Sidebar Menu
Sliding Panels for jQuery
jQuery ToggleElements
Coda Slider
jCarousel
Accesible News Slider Plugin
Showing and Hiding code Examples
jQuery Easing Plugin
jQuery Portlets
AutoScroll
Innerfade
Drag and Drop-拖拽
UI/Draggables
EasyDrag jQuery Plugin
jQuery Portlets
jqDnR - drag, drop resize
Drag Demos
XML XSL JSON Feeds
XSLT Plugin
jQuery Ajax call and result XML parsing
xmlObjectifier - Converts XML DOM to JSON
jQuery XSL Transform
jQuery Taconite - multiple Dom updates
RSS/ATOM Feed Parser Plugin
jQuery Google Feed Plugin
Browserstuff-瀏覽器相關
Wresize - IE Resize event Fix Plugin
jQuery ifixpng
jQuery pngFix
Link Scrubber - removes the dotted line onfocus from links
jQuery Perciformes - the entire suckerfish familly under one roof
Background Iframe
QinIE - for proper display of Q tags in IE
jQuery Accessibility Plugin
jQuery MouseWheel Plugin
Alert, Prompt, Confirm Windows-警告,提示,確認框
jQuery Impromptu
jQuery Confirm Plugin
jqModal
SimpleModal
CSS-樣式表單
jQuery Style Switcher
JSS - Javascript StyleSheets
jQuery Rule - creation/manipulation of CSS Rules
jPrintArea
DOM, Ajax and other jQuery plugins-DOm,ajax以及其他
FlyDOM
jQuery Dimenion Plugin
jQuery Loggin
Metadata - extract metadata from classes, attributes, elements
Super-tiny Client-Side Include Javascript jQuery Plugin
Undo Made Easy with Ajax
JHeartbeat - periodically poll the server
Lazy Load Plugin
Live Query
jQuery Timers
jQuery Share it - display social bookmarking icons
jQuery serverCookieJar
jQuery autoSave
jQuery Puffer
jQuery iFrame Plugin
Cookie Plugin for jQuery
jQuery Spy - awesome plugin
Effect Delay Trick
jQuick - a quick tag creator for jQuery
Metaobjects
elementReady
Friday, April 3, 2009
jQuery 似乎很好用,來學習一下吧
底下這篇是從 jQuery 的官網上抓下來的,可以作為學習 jQuery 的基礎,但發現另外一個 package 叫做 jQuery UI,我想這才是將 jQuery 發揮到淋漓盡致的使用方式吧
jQuery 的官網為 http://jquery.com/jQuiery UI 的官網為 http://jqueryui.com/home
jQuery UI 的測試網址可以到 http://jqueryui.com/demos
教學網址可以參考 http://jsgears.com/thread-63-1-1.html
Saturday, March 28, 2009
在 Web 上套用統計圖表 Jfreechart + cewolf
這個方式雖然可以解決統計圖顯示在 Web Page 上問題,但彈性太小,無法透過參數的方式指定圖形型態,大小,資料等,而 cewolf 這個 open source 便提供了此彈性的解決方案
Cewolf 在實作上是一個 JFreeChart 的 Wrapper 並提供 Tag Library 讓 Developer 可以方便的在 JSP 上套用統計圖表。要在 JSP 下顯示圖表可以參考以下步驟
1. Setup Libarary of JFreeChart and Cewolf
從 JFreeChart 與 Cewolf 下載 library 後,必須在 web.xml 中設定 servlet 與 servlet mapping 讓圖形可以透過此 mappng 讓 Browser 下載圖表
2. Add Chart into JSP
在 JSP 中若要加 JFreeChart 的圖表,需要加上 tag 如下 ([] 取代 <>)
[%@ taglib uri="/WEB-INF/cewolf.tld" prefix="cewolf" %]
[cewolf:chart id="line" title="EPS" type="verticalbar" xaxislabel="category" axislabel="value"]
[cewolf:data]
[cewolf:producer id="datasetProducer" /]
[/cewolf:data]
[cewolf:chartpostprocessor id="dataColor"/]
[/cewolf:chart]
[cewolf:img chartid="line" renderer="/cewolf" width="600" height="300" /]
3. Assign data to id associated to chart
這邊是用 struts 2 的方式,所以在 action 中加上 API 就可以當 id 用
public DatasetProducer getDatasetProducer() {
DatasetProducer producer = new DatasetProducer() {
/**
* Produces some random data.
*/
public Object produceDataset(Map params) throws DatasetProduceException {
log.info("producing data.");
// create the dataset...
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(100, "serial1", "category1");
dataset.addValue(120, "serial2", "category1");
dataset.addValue(120, "serial3", "category1");
dataset.addValue(130, "serial1", "category2");
dataset.addValue(140, "serial2", "category2");
dataset.addValue(140, "serial3", "category2");
return dataset;
}
/**
* This producer's data is invalidated after 5 seconds. By this method the
* producer can influence Cewolf's caching behaviour the way it wants to.
*/
public boolean hasExpired(Map params, Date since) {
log.debug(getClass().getName() + "hasExpired()");
//return (System.currentTimeMillis() - since.getTime()) > 5000;
return true;
}
/**
* Returns a unique ID for this DatasetProducer
*/
public String getProducerId() {
return "PageViewCountData DatasetProducer";
}
/**
* @see java.lang.Object#finalize()
*/
protected void finalize() throws Throwable {
super.finalize();
log.debug(this + " finalized.");
}
};
return producer;
}
public ChartPostProcessor getDataColor() {
ChartPostProcessor dataColor = new ChartPostProcessor() {
public void processChart(Object chart, Map params) {
CategoryPlot categoryplot = (CategoryPlot) ((JFreeChart) chart) .getPlot();
categoryplot.setDomainGridlinesVisible(true);
categoryplot.setRangeCrosshairVisible(true);
categoryplot.setRangeCrosshairPaint(Color.blue);
NumberAxis numberaxis = (NumberAxis)categoryplot.getRangeAxis();
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer barrenderer = (BarRenderer)categoryplot.getRenderer();
barrenderer.setDrawBarOutline(false);
GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
barrenderer.setSeriesPaint(0, gradientpaint);
barrenderer.setSeriesPaint(1, gradientpaint1);
barrenderer.setSeriesPaint(2, gradientpaint2);
barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}"));
CategoryAxis categoryaxis = categoryplot.getDomainAxis();
categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D));
}
};
return dataColor;
}
如此就可以在畫面上顯示
PS:
1. 在 cewolf:img chartid="line" renderer="/cewolf" width="600" height="300"中的 renderer 需要加上 "/" 因為 servlet 的 mapping 設定是以 "/" 為主
2. 這個 cewolf package 在 resin 下若顯示兩個圖表以上會有 bug
這邊提供一個範例 webchart ,提供給需要實作的人可以快速上手
Friday, March 27, 2009
學如逆水行舟,不進則退
從 struts 1.x 跳到 WebWork 可能無法接受,但跳到 struts 2.x 就滿容易的,設定檔其實差不多,只是在觀念上要改變,把 action 也當作 bean 看待便行了
說實在的,要進步,就要動起來。只守在原本的模式而不創新只會帶來退步而失去商機
Wednesday, March 25, 2009
Maven 使用技巧
最近看到一篇文章敘述如何成功的使用 Maven 作為 build tool ,每家公司都應該使用此 tool 作為軟體開發時的共同程式庫,減少要 start a new project 時所需要的時間,同時也可以將開發過的東西做成 Plugin ,隨時都可以引用
Five tips for successfully deploying Maven
- Use a repository manager
A repository manager is basically an on-demand mirroring repository cache that you set up inside your IT infrastructure and use as primary repository for your builds. They basically work like this: if you build a project that depends on, for example, commons-lang-2.4.jar, the repository manager will download the artifact from the main Maven repository on the web, cache it locally and return it to the build client that asked for it. All subsequent builds that use the same managed repository will get the commons-lang jar delivered from the cache, not from the web.
This has many advantages. First of all, it's fast. All project members, except the first one, will download any given dependency at LAN speed, which is especially nice when you're setting up a build environment from scratch (new project member, staging a clean build, etc). And of course it saves external bandwidth for other purposes and to lower costs.
Second, it's safer. It allows you to run centralized and incremental backups on all external dependencies that you projects use, and you reduce your dependency on the availability of public repositories.
Third, it's convenient. From time to time you will need a library that's not (yet) available in any public repository, so you have to publish it somewhere. A repository manager makes that really easy. And if you're sharing internal libraries or interfaces between projects, it's extremely handy to deploy to the managed repository. You can even set up your continuous integration build to automatically deploy snapshots.
I've had a pleasant experience working with Nexus, but there are others. A repository manager should be as natural a part of you infrastructure as SCM and CI if you're using Maven. - Specify plugin versions
By default, Maven will automatically download a new version of any given plugin whenever there is one available. Given that Maven is 99% made up of plugins (there's even a plugin plugin!), this is a potential point of breakage over time and in my opinion a design mistake.
As of version 2.0.9, the default behaviour is improved by locking down the versions of the core plugins (where "core" is defined by this list). However, you still need to explicitly define versions for all non-core plugins, and that can be done at the top level pom.xml in a hierarchial project using the pluginManagement section.
maven-assembly-plugin
2.2-beta-2
maven-antrun-plugin
1.2
Do this for the plugins that you actually use. Note that for plugins with group id org.apache.maven.plugin, you can omit the groupId element.
This will make your builds more stable and eliminate a fairly rare but very annoying and confusing set of problems. - Learn how to use the dependency plugin
Maven introduced the concept of transitive depedencies to the Java community, and has been a source of confusion ever since. The dependency plugin is an invaluable tool for analyzing the results of the dependency algorithm, and to handle dependencies in various ways. Here are a couple of things you can do with it:dependency:tree
shows (you guessed it) the dependency tree for the project, what dependencies are being pulled in and why. It's a nice overview and can help you tweak the dependency structure by excluding artifacts or override versions and so on. Example output:
[INFO] +- org.apache.activemq:activemq-core:jar:5.2.0:compile
[INFO] | +- org.apache.camel:camel-core:jar:1.5.0:compile
[INFO] | +- org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1.1:compile
[INFO] | +- org.apache.activemq:activeio-core:jar:3.1.0:compile
[INFO] | | \- backport-util-concurrent:backport-util-concurrent:jar:2.1:compile
[INFO] | \- org.apache.geronimo.specs:geronimo-j2ee-management_1.0_spec:jar:1.0:compiledependency:go-offline
Downloads all project dependencies and plugins, transitively. It's a good command to run both if you want to work offline for a while and if you want to get as many of the external dependencies in place in a single shot with no manual intervention while you go grab a cup of coffee and/or read another item in Effective Java ;-)dependency:copy
If you ever need to handle artifacts as files, copying all or some of them to a custom location for whatever reason, this is a good approach.
dependency:copy-dependencies
- Use the documentation
Well, duh. But a weak point of Maven in the eyes of many people is the lack of documentation and the sometimes poorly organized information. There are a few good points of reference though, that you can spread around you team by setting up links on the Wiki for example:- The Definitive Guide to Maven: a free book from Sonatype, available both as HTML and PDF. Good for the beginner, and sometimes as a reference. If you don't know where to start, start here.
- The plugin list: a comprehensive list to the official plugins, with links to each project page and JIRA subsection. Most of the core functionality is actually performed by one of these plugins, and you can learn a lot by studying things like the resources plugin documentation.
- The POM reference: for the slightly more advanced user. Every element in the POM is explained. Don't forget to specify the XSD information in your POM file to get the most help from your XML editor.
- The Definitive Guide to Maven: a free book from Sonatype, available both as HTML and PDF. Good for the beginner, and sometimes as a reference. If you don't know where to start, start here.
- Understand the conventions
Maven is a conventions-based tool, relieving you from scripting common task like compiling source code, running tests or packaging a web application into a war file. Learning the conventions - directory structure, build phases - and working along them will make your life easier a lot of the time.
There are definitely situations even in moderately sized projects to customize the build however, and Maven can sometimes be quite cumbersome to work with when you need to break the conventions. But by understanding the conventions and having the mindset that there is a good chance what you're trying to do can be accomplished within the realms of the conventions, you might be able to find a different approach than you otherwise might have.
Perhaps that ugly jar-splitting, file-copying, token-replacing antrun hack that you spent an agonizing week writing could be replaced by extracting part of the project into a separate module and included as a dependency instead? It's a lot easier to swim downstream than upstream.
Maven just released version 2.1.0 with many improvements. Another build tool that shows great promise is Gradle, which combines transitive dependencies and conventions à la Maven, the Ant task library and the scripting abilities of Groovy.
Saturday, January 31, 2009
Essential Java Resources(必備 Java 資源)
Web sites and developer Web portals
Weblogs
Packages and/or libraries
- java.lang.reflect
- javax.script
- javax.management and java.lang.management
- java.util.concurrent.*
- java.util
- java.beans
- java.util.logging
- java.security.*
- javax.xml.parsers.*, javax.xml.bind, and javax.xml.transform.*
- javax.sound.*
- Effective Java (2nd Ed) by Joshua Bloch
- Java Concurrency in Practice by Brian Goetz
- Better, Faster, Lighter Java by Justin Gehtland and Bruce Tate
- Effective Enterprise Java by Ted Neward (me)
- Release It! by Michael Nygard
- Either Inside the Java 2 Virtual Machine by Bill Venners or Component Development for the Java Platform by Stuart Halloway
- Patterns of Enterprise Application Architecture by Martin Fowler and Enterprise Integration Patterns by Gregor Hohpe and Bobby Woolf
- Java Power Tools by John Smart
- The Pragmatic Programmer by Andy Hunt and Dave Thomas
- The Productive Programmer by Neal Ford
- The Pragmatic Starter Kit
- Ant in Action (2nd Ed) by Erik Hatcher and Steve Loughran
- The IDE
Of course, the tools discussion begins with the IDE. In an effort to steer clear of commercial endorsements, both Eclipse and NetBeans are open source and free and thus offer an attractive "first steps" option. - Unit testing
The perennial favorite here is the original that started the unit testing revolution, JUnit, but a few others have crept into popular usage, including TestNG, and not surprisingly JUnitPerf, among others. - Continuous Integration
A Continuous Integration server constantly checks the code out of source control, builds it, runs the unit tests against it, and reports any build failures to the developers, usually via e-mail. Several open-source versions are available, but one that has gathered a lot of attention is Hudson, a Continuous Integration server with a lot of plug-ins and high extensibility. The original is CruiseControl and for that reason alone commands respect. - Static analysis
FindBugs is an open-source static analysis tool that runs over Java code, performs deep n-way analysis to figure out all the possible code paths, and reports all sorts of errors and warnings it finds, based on a set of extensible rules. Developed by William Pugh (the same William Pugh who discovered a bug in the Java memory model), FindBugs' biggest claim to fame is its ability to analyze Java code for concurrency bugs, something that every programmer can appreciate. - Network packet tracing
WireShark (which formerly used to be called Ethereal) gives programmers a view of what's traveling across the network, giving them an opportunity to verify that what's moving across the wire is what's supposed to be moving across the wire, and that what's not supposed to be there (such as sensitive information or passwords in clear text), isn't. - Virtualization
A virtualization tool (or perhaps it is more accurate to call it a platform) like VMWare, Xen, VirtualBox, or VirtualPC offers programmers the ability to create an environment identical to the one the production machine will be running without losing the productivity of the environment of the host PC. It also provides a convenient way to have a home for trying "experimental" software without risking the machine that has to stay productive. Most of these have some kind of free option if they're not outright open-source projects.
以上都是在使用 Java 寫系統時最好先須具備的 Resource ,這樣才能隨時參考到資料並做最有效的運用
Thursday, January 29, 2009
如何清除 Microsoft SQL2000, SQL2005 的 log 檔
若平常有做備份,其實這些 transaction log 是可以不要的。要去除這些 log ,可以利用 MSSQL 內建的指令去除,可以參考以下步驟
1. 找出 log file 目錄
要縮小這些 log ,必須先找出 log 到底有多大。這個 log file 普通都會跟資料檔放在同一個目錄,在 MSSQL 2005 的系統裡面,預設放資料檔的目錄為
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\
副檔名為 mdf 的為資料檔, 副檔名為 ldf 的為 transaction log 檔
2. 縮小 log file
打開 SQL2005 的 Server Management Studio 或 SQL2000 的 Analyzer,然後執行以下指令
=======================================
USE [master]
ALTER DATABASE [master]
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (mastlog, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE [master]
SET RECOVERY FULL;
GO
=========================================
這邊需注意的是,[master] 與 [mastlog] 是邏輯名稱 (logical name),不是資料檔名稱
注意事項
1. 一但將這些 log file 清除,就無法做 transaction 的 recovery。
何謂 transaction 的 recovery ,就是可以利用之前的備份,將資料 recover 到特定日期。如今天是 2009/1/30,若要將資料庫還原到 1/27 的狀態,則需有 2009/1/25 的 full backup,便可以配合 1/26, 1/27 的 transaction backup ,將資料庫 recover 到 1/27 的狀態。
2. 做清除 transaction log 前最好先做 full backup ,以防萬一。
Thursday, January 8, 2009
如何用 appfuse 2.0.2 透過 gmail 發信
因為 gmail 用的 SMTP 走的是 SSL 機制,所以設定上比較麻煩一點
以下是用 gmail 發信的 mail.properties 範例
mail.default.from=Name <xyz@gmail.com>
mail.debug=true
mail.transport.protocol=smtp
mail.username=xyz@gmail.com
mail.password=secret
mail.port=587
mail.mime.address.strict=false
mail.mime.charset=UTF-8
雖然有點 tricky, but it works