2011年3月29日 星期二

[eclipse] JDK版本不一樣導致WTP項目錯誤

錯誤信息:Java compiler level does not match the version of the installed Java project facet.

解决方法: 專案點右鍵,選Properties,再選Project Facets,可以看到目前的JDK版本,選擇與menu中的 windows => preference中的 java => install JREs 的版本是要一致的

2010年11月12日 星期五

[Android] uses-permission 備註

AndroidManifest.xml 的 uses-permission 意義

頭尾是用"<"uses-permission">"包起來

android:name=”android.permission.INTERNET”
允許程式存取 internet

android:name="android.permission.ACCESS_NETWORK_STATE"
照字面的意思應該是允許程式存取網路的狀態吧!

android:name="android.permission.RESTART_PACKAGES"
以經不被支援了(This constant is deprecated. The restartPackage(String) API is no longer supported)

android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
(Allows mounting and unmounting file systems for removable storage.)
允許安裝和卸載在可移動存儲設備上吧

android:name="android.permission.WRITE_EXTERNAL_STORAGE"
寫入外部的儲存設備(應該是指SD Card)

android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"
(Allows an application to change whether an application component (other than its own) is enabled or not.)
允許一個程式是否改變一個組件或其他的啟用或禁用

android:name="android.permission.WRITE_CONTACTS"
(Allows an application to write (but not read) the user's contacts data.)
允許這個AP寫入(但不會讀出)用戶的聯絡人
 
android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"
(Allows an application to access extra location provider commands)
允許應用程式訪問額外的位置提供命令

2010年8月5日 星期四

[Tomcat] 啟動錯誤


2008/5/10 上午 04:51:08 org.apache.catalina.core.AprLifecycleListener init
資訊: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_05\bin;....


有人找到原因:

原來Tomcat從5.5版本後增加了APR技術(Apache Portable Runtime),這是一個用C語言寫成文件包,目的在於提高Tomcat的服務性能,從而使得Tomcat將不僅僅擔任一個容器的功能,而是要成為一個一般的web服務器(general purpose webserver)。

可以知道的是,原來預設的版本都沒有附加那個檔案!
因此,請各位到Tomcat網站上去下載:http://tomcat.apache.org/download-native.cgi
進去後找到 You may download them from HERE 連結,
在裡面找一個版本編號是最新的,進去後去下載一個叫 tcnative-1.dll 的檔案。
下載下來的tcnative-1.dll 的檔案,如果各位有設定JAVA_HOME的環境變數,
就直接把此檔案放進去 %JAVA_HOME%\bin 的目錄底下即可!

重新啟動Tomcat

2008/5/10 上午 04:42:00 org.apache.catalina.core.AprLifecycleListener init
資訊: Loaded Apache Tomcat Native library 1.1.12.

我使用的版本為5.5.30

參考來源:http://www.javaworld.com.tw/jute/post/view?bid=9&id=227419&sty=1&tpg=1&age=0

2010年8月3日 星期二

2010年7月14日 星期三

[Java] 檔案刪除 File.delete()

application.getRealPath("")為抓取真實路徑

File file = new File(application.getRealPath("abc.txt")); //jsp user
或是
File file = new File("c:/abc.txt")

file.delete();

2010年7月8日 星期四

[Jsp] 檔案上傳(org.apache.commons.fileupload)

FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);

List  items = upload.parseRequest(request);
   
   Iterator iter = items.iterator();
    while (iter.hasNext()) {
        FileItem item = (FileItem) iter.next();

        if (item.isFormField()) {
           //一般的request item
            String name = item.getFieldName();
            String value = item.getString();
            out.println(name + "=" + item.getString("UTF-8"));
        } else {
            // 如果是上傳檔案, 就在這接收
            //processUploadedFile(item);
            String fieldName = item.getFieldName();
            String fileName = item.getName();
            String contentType = item.getContentType();
            boolean isInMemory = item.isInMemory();
            long sizeInBytes = item.getSize();
            out.println("fieldName="+fieldName+"");
            out.println("fileName="+fileName+"");
            out.println("contentType="+contentType+"");
            out.println("isInMemory="+isInMemory+"");
            out.println("sizeInBytes="+sizeInBytes+"");
            if (fileName != null && !"".equals(fileName)) {
                fileName= FilenameUtils.getName(fileName);
                out.println("fileName saved="+fileName+"");
                File uploadedFile = new File(saveDirectory, fileName);
                item.write(uploadedFile);
            }
        }
    }           

2010年7月7日 星期三

[Hibernate] 使用hibernate會使用到的jar檔

hibernate-distribution-3.5.3-Final  require lib
antlr-2.7.6.jar
c3po-0.9.1.2.jar
cglib-2.2.jar
commons-collections-3.1.jar
commons-logging-1.1.jar
dom4j-1.6.1.jar
ehcache-1.2.3.jar
hibernate3.jar
javassist-3.9.0.GA.jar
jta-1.1.jar
slf4j-api-1.6.0.jar
slf4j-jcl-1.6.0.jar

有用到ehcach才使用ehcach
有用到c3po才使用c3po