2011年10月30日

          今天廢了老勁了,終于找到為何deploy/lib目錄下一個包從哪里來的了。在項目的dependency里沒有發現這個包,但是deploy目錄下總可以找到。

          查了半天,終于發現了,在項目dependency里依賴到的第三方的一個包里它依賴到了我需要查找的包,導致這個包被貌似莫名其妙的進入到了deploy/lib下面。
          posted @ 2011-10-30 18:56 simplelove 閱讀(220) | 評論 (0)編輯 收藏

          2010年8月18日

          Attended Scrum training theses two days.

          Some highlights from the training:

          1. Scrum master is a facilitator, does not assign task. Team owns tasks itself.
          2. Each feature has a unique rank, decided by product owner and scrum master and the team. Always finish rank high feature first, before continue rank low feature.
          3. Scrum always encourage communication and collaboration.
          4. Scrum is not a project management, but a framework for all the teams to do the things in same way. Project management methodology is still needed in Scrum.
          5. Scrum deliver value sooner than waterfall method.
          6. Scrum fits the product/project that requirements are not so fixed.
          7. Each team/person has its own customer.
          8. Successful software development projects are mainly based on people interactions.
          9. Advocate zero defect in iterations, ready to release after each iteration.
          10. XP is next level of Agile after Scrum.
          posted @ 2010-08-18 10:48 simplelove 閱讀(273) | 評論 (0)編輯 收藏

          2010年7月30日

          I upgraded to IntelliJ IDEA 7.0 the day it came out and was, at first, let down by how poorly it performed on my machine. Since then, I tweaked a bunch of settings, and now have it performing just as fast as IDEA 5 ever did on the same box. Enjoy, and happy coding!
          1. Change your Look and Feel
          Change your look and feel to something other than native. On Windows, the “IDEA (4.5 Default)” look and feel performs much better than the native one. On Mac, just pick something other than the native. The new graphics will bother you for about 30 minutes and then you’ll forget all about them. This setting is in the Settings (Ctrl+Alt+S) -> Appearance (B) dialog. (Tip courtesy of Howard Lewis Ship)
          2. Use Structure View Instead of Project View
          In IDEA 7.0.2 on Windows, I seem to pay a heavy performance price for the Project View (Alt+1), especially with autoscrolling to and from source enabled. My alternative is to use the Structure View (Alt+2) as my default sidebar and rely on the Navigation Bar (View->Navigation Bar) for project navigation. I find I actually prefer this setup and 7.0.2 performs noticeably faster.
          3. Turn off Synchronize Files
          When you activate the IDEA frame, IDEA will scan the disk for file changes, giving you a nice progress bar to wait for. If you’re not editing files outside of IDEA then turn this feature off in Settings (Ctrl+Alt+S) -> General (A). Uncheck “Synchronize Files on Frame Activation”. Now you’ll have to manually synchronize the files using Ctrl+Alt+Y (File->Synchronize on the menu). (Tip courtesy of Tyler)
          4. Disable Spring Model Validation on Build
          I used to get a progress bar every time I ran or debugged my project, with the message “Validating Spring Model”. I don’t need this feature except when I’m working on the Spring files, so I turned it off. Settings (Ctrl+Alt+S) -> Project Settings (1) -> Modules… then click Spring, then click the Options Tab. Deselect the checkbox for “Enable Spring model validation on build”.
          5. Disable Unused Plugins
          Disable all of the plugins you are not currently using. For example, if you’re not using Geronimo, Commander or Jabber, then turn them off. Settings (Ctrl+Alt+S) -> Plugins (T). Uncheck anything you have installed that is unused (Tip courtesy of Carl)
          6. Use Scopes to Speed Up Searches
          I rarely really want to search my entire project for a string or reference. Any search dialog allows you to pick a custom scope, such as production files or test files. But “Changed Files” is a helpful option too. On large, monolithic projects you may want to define your own to only search certain packages. A little time creating new scopes will save you a lot of time in waiting for searches to complete. Define scopes in Settings (Ctrl+Alt+S) -> Scopes (5).
          7. Increase Your Heap Size
          Several sources include directions on increasing your heap size in IDEA. This is changed in your idea.exe.vmoptions file.
          8. Always Get the Latest Version
          I’ve already suggested this, so I’ll be brief. Each minor release seems to have good performance improvements.
          9. Reduce Size of Local History
          Another blog recommended that you turn off or reduce Local History. I love this feature so I’ll never turn it off, but the default is to save 3 days worth of work. I typically check in to version control more often than that, so I trimmed it up to 1 day of history. Do this in Settings (Ctrl+Alt+S) -> Local History (J).
          10. Optimize Your Disk?
          I haven’t tried this myself, but the tip came directly from JetBrains. Beyond just defragmenting, you can also optimize the MFT tables, disk folder structure, and the paging file. Direction appear on their site. Simply upgrading to a newer hard drive is find at home, but I don’t have that much control of my work machine. It’s Friday, so I’ll try this today. If things go horribly wrong I’ll redact the entry!
          ————————————————————————————————————————————————————————————————————————————
          IntelliJ IDEA Performance
          There're some concerns about IntelliJ IDEA Performance. And here is the tips that I used to make mine run fast. Some of them come from my own experience, some of them come from the know-everything internet.
              * Make sure you have all your libraries on your local harddrive (as opposed to mounted network drive). After I moved all my libraries from a network drive to local harddrive, the time for a 'make' on the project is reduced from around 60 seconds to just 5-7 seconds!
              * Defragment your Disk and reboot your computer. IDEA creates lots of small files and too much fragmentation is a nightmare.
              * Turn off Anti Virus completely. Yes I mean completely. It affects the performance dramatically.
              * Turning off Local History or even reducing the number of history days improved the performance significantly.
              * Adjust VM settings. Here is my idea.exe.vmoptions file (on windows):
          -Xms512m
          -Xmx512m
          -XX:MaxPermSize=99m
          -ea
          Change it as you see fit per your hardware configuration.
          More information is available at http://blogs.jetbrains.com/idea/2006/04/configuring-intellij-idea-vm-options/.
              * The Debugger in IDEA may work slowly if the Force classic VM option is not selected in the File Project Properties Debugger dialog. Using Method Breakpoints may also slow down the debugging process. I had two breakpoints on the method name instead of the first line of the method. It was taking a half hour to get to the breakpoint Changing these to line breakpoints gave me two orders of magniture
              * You may notice IDEA hang for several seconds when you switch to it from other applicationDisable Settings General Synchronize files on frame activation.
              * Disable windows paging file if you have enough memory. Get more memory if you don't have enough. Swapping is a performance nightmare.
              * Turn off windows indexing services, either set it to Disabled or Manual unless you do lots of file system search (even you do, I recommend Google Desktop Search). IDEA use lots of small files so background indexing can have a big negative effect on it's performance.
              * Control Panel/System/Properties/Advanced/Visual Effcts, Adjust for best performance. Unless you're willing to sacrify performance for visual effects like windows animation, fading/sliding etc.

          posted @ 2010-07-30 01:40 simplelove 閱讀(1413) | 評論 (0)編輯 收藏

          2010年6月30日

          一般而言,兔子在出生兩個月后,就有繁殖能力,一對兔子每個月能生出一對小兔子來。如果所有兔都不死,那么一年以后可以繁殖多少對兔子?

            我們不妨拿新出生的一對小兔子分析一下:

            第一個月小兔子沒有繁殖能力,所以還是一對;

            兩個月后,生下一對小兔民數共有兩對;

            三個月以后,老兔子又生下一對,因為小兔子還沒有繁殖能力,所以一共是三對;

            ------

            依次類推可以列出下表:

            所經過月數:0、1、2、3、4、5、6、7、8、9、10、11、12

            兔子對數:1、1、2、3、5、8、13、21、34、55、89、144、233

            表中數字1,1,2,3,5,8---構成了一個序列。這個數列有關十分明顯的特點,那是:前面相鄰兩項之和,構成了后一項。

            這個數列是意大利中世紀數學家斐波那契在<算盤全書>中提出的,這個級數的通項公式,除了具有a(n+2)=an+a(n+1)/的性質外,還可以證明通項公式為:an=1/√5[(1/2+√5/2)^ n-(1/2-√5/2)^ n](n=1,2,3.....)(√5表示根號5)

            這個通項公式中雖然所有的an都是正整數,可是它們卻是由一些無理數表示出來的

          posted @ 2010-06-30 09:17 simplelove 閱讀(303) | 評論 (0)編輯 收藏

          2010年6月8日

          If you want the entry to be garbage collected, use WeakHashMap. Once the key is not strongly referenced, the entry will be automatically reclaimed.

           

          Here is a good article to understand this:

          http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html

          posted @ 2010-06-08 20:40 simplelove 閱讀(296) | 評論 (0)編輯 收藏

          2010年6月4日

          附錄 A. 需要搞清楚幾個問題
          A.1. Maven2的優點
            1.
            對第三方依賴庫進行統一的版本管理。
            只要用了Maven2就不用再為每個項目復制spring.jar和hibernate.jar了,Maven2會在你需要的時候,自動把這些第三方依賴庫找到,你需要編譯,Maven2就把這些jar包放到classpath里,你需要打包,Maven2就幫你把需要的jar包都復制到WEB- INF/lib/目錄下。
            2.
            統一項目的目錄結構。
            可以保證所有項目的目錄結構都是一樣的,目錄結構統一的好處就是,你要找源代碼就去src/main/java/下,你要找需要放到classpath下的資源,就去src/main/resources/下,你要找單元測試對應的代碼和資源,就去src/test/下。每個目錄下放什么東西,程序編譯,發布的時候,每個目錄起什么作用都很清楚明了,不會出現打開項目找不到要找的文件的情況。
            3.
            統一軟件構建階段
            Maven2把軟件開發的過程劃分成了幾個經典階段,比如你先要生成一些java代碼,再把這些代碼復制到特定位置,然后編譯代碼,復制需要放到 classpath下的資源,再進行單元測試,單元測試都通過了才能進行打包,發布。
            以前使用Ant,最令人頭疼的就是要為不同的項目寫很多build.xml腳本,而且這些腳本還不太通用,現在我們可以使用Maven2提供的這些經典構建階段,讓每個項目就經過相同的步驟,從源代碼一步一步變成可以部署的成品。如果想要什么附加功能,把對應的插件綁定到一個構建階段上,那么到了執行這個構建階段的時候,就會執行綁定的插件了。
            4.
            支持多種插件
            在http://maven.apache.com/和http://mojo.codehaus.org/上可以找到大量的Maven2插件,通過這些插件可以完成多種多樣的擴展功能。
            不過,如果比插件的易用性,Ant的插件實際上更簡單方便,與之相比,在Maven2中配置插件的步驟太復雜了,既要配置groupId和 artifactId,還要配置綁定在哪個階段運行。
            不過因為Maven2可以把插件連同第三方依賴一起進行統一版本管理,所以這方面也算比Ant有一點兒優勢,至少使用時不需要自己再去下載插件的發布包了。
            5.
            自動生成項目網站和報表
            如果說Ant可以使用ivy實現第三方依賴庫的統一管理,如果說Ant可以自己統一項目的目錄結果,如果說Ant支持插件更靈活,那么這個特性絕對是 Ant無法比擬的。
            Maven2 可以自動為項目生成一個網站,里面包含了項目信息,參與人,項目管理相關的資源,第三方依賴庫,使用的插件,以及通過其他擴展插件生成的各種報表。Ant 使用某些插件也可以生成html格式的報表,但是各個報表之間都沒什么關聯,不像Maven2中將網站和報表都關聯在一起,查看起來十分方便。
          A.2. Maven2的問題
            1.
            Maven2使用前需要像Ant一樣需要配置環境變量。
            本來綠色安裝是一件好事,但是因為太多人都只會用IDE,不了解如何配置環境變量,所以這第一步就很成問題。
            2.
            Maven- 2.1.0本身只有2.844M,可是這只是一個核心,實際使用時,還需要去公網上的資源庫下載各種插件,然后才能實現各種功能,問題是公網上的資源庫一般都是在國外,網路速度稍慢就無法完成下載,沒法下載就沒法使用Maven2里提供的那些功能,Maven2就用不起來。
            尤其對于新手來說,第一次下載插件的過程,實在是太痛苦了,大多數人都在這一階段放棄了對Maven2的嘗試。
            3.
            第三方依賴庫版本混亂。
            java的依賴庫管理一直沒有約定規范,導致多個項目,引用多個第三方依賴,這些第三方依賴又使用同一個項目的不同版本的發布包,最后就是弄得一團糟。
            Maven2 嘗試通過一些約定解決這個版本混亂的問題,但實際上并沒有達到預想中的效果。例如,commons.apache.org中的項目,本來應該放在 org/apache/commons/目錄下,現在卻都各自放在commons-logging,commons-lang,commons- beanutils目錄下,估計這是因為剛開始使用Maven2的那些人,懶得把常用包放到那么深的目錄結構中,偷懶放到了頂級目錄下??呻S著 Maven2的發展,加入資源庫的包越來越多,他們又把新發布的依賴包按照正常的方式,放到了org/apache/commons/目錄下,而舊依賴還有很多人在用,所以也不能刪除,這就造成了現在這種一種依賴庫多種存放形式的問題。
            每次在資源庫上找依賴都要花費很多時間,因為你不清楚它究竟使用的哪種目錄形式,比如sourceforge.net上的項目就有兩種目錄形式,一些項目放在net/sf /目錄下,而另一些例子放在net/sourceforge/目錄下,所以你就算知道項目的網站地址,也要在多個目錄下都找一遍。
            4.
            缺乏詳細的教程
            入門教程一般都很簡略,現在似乎使用的人多了起來,可以在網上找到一些新手教程,但是一般都很簡略,只能自己玩玩,實際中遇到問題的話,還是很難解決。
            實際上Maven2的教程一直是一塊短板,就算是國外的兩本書《Maven: The Definitive Guide 》和《Better Build With Maven》也沒有涉及到富含價值高級技術。
            就算是講的比較詳細的Maven2教程,也都是停留在Maven2本身的使用上,或者稍微提及一下使用到得官方插件,對于很多強力的擴展插件都沒有介紹。
            至今很多人用Maven2都處在摸索階段,沒看到誰總結出使用Maven2最佳實踐。這點上,一般都是把國外開源項目中的pom.xml拿來研究學習。
            5.
            資源庫不完整
            一般來說,我們可以從Maven2的資源庫上下載到我們所需要的第三方依賴庫,但是有些依賴庫在Maven2的資源庫上是找不到的。
            其中有因為發布協議的限制,比如j2ee的一些規范api。有因為項目所在廠商的原因,比如jbpm。有因為項目社區的問題,比如birt。還有很多情況是因為Maven2官方處理事情太慢,很多小型開源項目,比如dozer,雖然兩個月前就已經提出了最新版本的上傳申請,但是遲遲沒有給予答復。
            在這種情況下,我們只能自己在本地資源庫中安裝需要的依賴了,造成的問題是,如果相關的項目使用了Maven2的項目管理文件,那么可以使用Maven2 將項目發布到本地庫中,這樣一來就可以獲得項目自身的依賴設置。如果相關項目沒有使用Maven2的項目管理文件,那么需要自己再去為這個項目找到所需要的依賴,并配置到對應的pom文件中,著實非常麻煩。
            6.
            Maven2沒有IDE支持
            沒有良好的IDE支持也是個大問題,雖然說有m2eclipse,但是實際上似乎沒那么易用。
            本身我們沒有使用m2eclipse,而是使用maven2 + editplus的組合,不過介于廣大開發者還是要用eclipse的,所以稍后我們還是會討論到m2eclipse的相關知識。

          posted @ 2010-06-04 15:49 simplelove 閱讀(5587) | 評論 (0)編輯 收藏

          2010年5月23日

          follow steps 不用netbean,按照下文的指示手工操作。

          http://dev.firnow.com/course/3_program/java/javajs/20090507/166773.html

          碰到問題:

          在執行 ant -f build.xml setup的時候會報一個錯誤
          連接到端口1527上的服務器localhost 時出錯,消息未connetion refused:connect

           

          原因是java derby db 沒有啟動。

          解決方法:啟動它

          <glassfish_dir>/bin/asadmin start-database

          <glassfish_dir>指的是glassfish的安裝目錄

          posted @ 2010-05-23 15:51 simplelove 閱讀(340) | 評論 (0)編輯 收藏

          2010年4月16日

          image

          I got above error notes shows google take serious consideration about its security.

          posted @ 2010-04-16 11:26 simplelove 閱讀(156) | 評論 (0)編輯 收藏

          2010年2月20日

          • must end with a new line
          • Main-Class attribute is case sensitive
          • file name is random, file extension is mf, eg. mymanifest.mf
          • example jar command to package a app: jar cfm myapp.jar MANIFEST.MF *.*
          eg:

          Manifest-Version: 1.0
          Main-Class: ButtonTest


          posted @ 2010-02-20 14:15 simplelove 閱讀(743) | 評論 (0)編輯 收藏

          2010年2月15日

          When developing a Java program it is important to select the appropriate Java Graphical User Interface (GUI) components. There are two basic sets of components that you will most likely build your Java programs with. These two groups of components are called the Abstract Window Toolkit (AWT) and Swing. Both of these groups of components are part of the Java Foundation Classes (JFC).

          An Overview of the AWT

          AWT stands for Abstract Window ToolKit. The Abstract Window Toolkit supports GUI Java programming. It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window Toolkit provides the connection between your application and the native GUI. The AWT provides a high level of abstraction for your Java program since it hides you from the underlying details of the GUI your program will be running on.

          AWT features include:

          • A rich set of user interface components.
          • A robust event-handling model.
          • Graphics and imaging tools, including shape, color, and font classes.
          • Layout managers, for flexible window layouts that don't depend on a particular window size or screen resolution.
          • Data transfer classes, for cut-and-paste through the native platform clipboard.

          The AWT components depend on native code counterparts (called peers) to handle their functionality. Thus, these components are often called "heavyweight" components.

          An Overview of Swing

          Swing implements a set of GUI components that build on AWT technology and provide a pluggable look and feel. Swing is implemented entirely in the Java programming language, and is based on the JDK 1.1 Lightweight UI Framework.

          Swing features include:

          • All the features of AWT.
          • 100% Pure Java certified versions of the existing AWT component set (Button, Scrollbar, Label, etc.).
          • A rich set of higher-level components (such as tree view, list box, and tabbed panes).
          • Pure Java design, no reliance on peers.
          • Pluggable Look and Feel.

          Swing components do not depend on peers to handle their functionality. Thus, these components are often called "lightweight" components.

          AWT vs. Swing

          There are, of course, both pros and cons to using either set of components from the JFC in your Java applications. Here is a summary:


          AWT:
          Pros

          • Speed: use of native peers speeds component performance.
          • Applet Portability: most Web browsers support AWT classes so AWT applets can run without the Java plugin.
          • Look and Feel: AWT components more closely reflect the look and feel of the OS they run on.
          Cons
          • Portability: use of native peers creates platform specific limitations. Some components may not function at all on some platforms.
          • Third Party Development: the majority of component makers, including Borland and Sun, base new component development on Swing components. There is a much smaller set of AWT components available, thus placing the burden on the programmer to create his or her own AWT-based components.
          • Features: AWT components do not support features like icons and tool-tips.

          Swing:
          Pros

          • Portability: Pure Java design provides for fewer platform specific limitations.
          • Behavior: Pure Java design allows for a greater range of behavior for Swing components since they are not limited by the native peers that AWT uses.
          • Features: Swing supports a wider range of features like icons and pop-up tool-tips for components.
          • Vendor Support: Swing development is more active. Sun puts much more energy into making Swing robust.
          • Look and Feel: The pluggable look and feel lets you design a single set of GUI components that can automatically have the look and feel of any OS platform (Microsoft Windows, Solaris, Macintosh, etc.). It also makes it easier to make global changes to your Java programs that provide greater accessibility (like picking a hi-contrast color scheme or changing all the fonts in all dialogs, etc.).
          Cons
          • Applet Portability: Most Web browsers do not include the Swing classes, so the Java plugin must be used.
          • Performance: Swing components are generally slower and buggier than AWT, due to both the fact that they are pure Java and to video issues on various platforms. Since Swing components handle their own painting (rather than using native API's like DirectX on Windows) you may run into graphical glitches.
          • Look and Feel: Even when Swing components are set to use the look and feel of the OS they are run on, they may not look like their native counterparts.
          posted @ 2010-02-15 10:58 simplelove 閱讀(687) | 評論 (0)編輯 收藏
          僅列出標題  下一頁

          導航

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          統計

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 平定县| 大洼县| 汶川县| 滨州市| 山东| 泸西县| 右玉县| 江津市| 同江市| 沅江市| 萨嘎县| 阜城县| 永定县| 上思县| 宜宾市| 南充市| 茌平县| 肥东县| 浙江省| 青浦区| 延寿县| 磐石市| 准格尔旗| 蓬莱市| 泰兴市| 永和县| 类乌齐县| 南宁市| 齐齐哈尔市| 巴林右旗| 平昌县| 饶阳县| 松滋市| 乳源| 平顶山市| 彭山县| 宾川县| 罗甸县| 察哈| 朝阳县| 永春县|