26 มิ.ย. 2555

Install tomcat on window

Install tomcat server for use war file Generate by Java

1. Download Tomcat 6  http://tomcat.apache.org/download-60.cgi
 and extract zip file to drive C:\Program Files

2. Download Java JDK (Java SE 6 Update 33) http://www.oracle.com/technetwork/java/javase/downloads/index.html
 and install set JAVA_HOME by path of JDK "C:/Program Files/java/jdk/" not JRE

3. After install Java use "cmd" go to "~/tomcat/bin" and "service.bat install" in "cmd" 
Go to Control Panel Adminstrator Tools -> Service and Start "Apache Tomcat Server" open http://localhost:8080 or http://127.0.0.1:8080 Work!! 
but don't  open  try to close Window Firewall

4. Copy war file "yourservice.war" to C:\Program Files\apache-tomcat-6\webapps and url:http://localhost:8080/yourservice

SET Encoding for Tomcat Window

Try setting the (Windows) environment 

variable JAVA_TOOL_OPTIONS to -Dfile.encoding=UTF-8and 

start the Tomcat Server.

18 มิ.ย. 2555

Play Framework ทำเว็บด้วย Java กัน

  1. Download file play framework จาก http://www.playframework.org/ แตก zip ไฟล์ที่ได้ไว้ใน  Directory นึง

  2. Set Envoirment path โดยใส่ path ของ Directory Play framework ที่เรา แตก zip ไว้ restart เครื่อง
  3. สร้าง Application โดยทำการเปิดหน้าต่าง command line หรือ cmd นั่นเอง พิมพ์
    "play new ชื่อProject " เมื่อพิมพ์เสร็จแล้วก็จะได้ Folder ที่ข้างในจะมี ส่วนของการทำงานต่างๆโดยจะแบ่งเป็น Folder ดังนี้
    1.   "app/" contains the application’s core, split between models, controllers and views directories. This is the directory where .java source files live.
    2.   "conf/" contains all the application’s configuration files, especially the main appliation.conffile, the routes definition files and the messages files used for internationalization.
    3.   "project/" contains the build scripts. The build system is based on sbt. But a new play application comes with a default build script that will just works fine for our application.
    4.   "public/" contains all the publicly available resources, which includes JavaScript, stylesheets and images directories.
    5.   "test/" contains all the application tests. Tests can be written as JUnit tests. 

  4. เข้าไปใน Folder Project เราพิมพ์ "play" จะขึ้นชื่อ Project มาต่อไปพิมพ์ "run" รอสักพัก ก็จะขึ้นแบบนี้


    ภาพจาก http://www.playframework.org/documentation/2.0.1/JavaTodoList

    ทำการเข้าเมื่อโปรแกรม run เสร็จแล้วที่ http://localhost:9000/




    วันนี้เท่านี้ก่อนนะครับวันหลังจะมาต่อเรื่องการใช้ play ร่วมกับ IDE Eclipse