Heap vs Stack vs Perm Space

Heap space: All live objects are allocated here.
Stack space: Stores references to the object for variable in method call or variable instantiation.
Perm space: Stores loaded classes information

For example:

Student std = new Student();

After executing the line above memory status will be like this.

Heap: stores "new Student()"
Stack: stores information about "std"
Perm Space: stores information about Student class

JVM config

-Xms512m -Xmx1024m -XX:PermSize=64MB -XX:MaxPermSize=512M

-Xms512m: JVM heap initial size
-Xmx1024m: JVM heap max size

----java.lang.OutOfMemory

Perm: Permanate generation
-XX:PermSize: JVM perm initial size
-XX:MaxPermSize=512ML JVM perm max size

----java.lang.OutOfMemoryError: PermGen space

chat.js


nc localhost 8000  (open in several sessions)

tcp-server.js

 var net = require('net');

 var server = net.createServer(function(socket) {
     socket.write('hello\n');
     socket.end('world\n');
  });

 server.listen(8000);
telnet localhost 8000
nc localhost 8000
hello
world

web-server.js


var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(3000, '127.0.0.1');

console.log('Server running at http://127.0.0.1:3000/');
curl http://localhost:3000
Hello World

Input file specified two times

For some reason, this morning, I started seeing this error when I was trying to use todo

Input file specified two times

Here is the fix:

edit todo.config

export TODOTXT_SORT_COMMAND='/bin/sort -f -k2'

How to debug in Eclipse with webshpsere

Go to http://localhost:8091/ibm/console/, login in.

Servers->Server Types->WebShpere application servers->server1
Additional Properties->Debugging service
Check "Enable service at server startup"
Check "JVM debug port", usually it's 7777, this is the port number that you will use.
Click Apply, then click Save directly to the master configuration.
A restart on WebShpere is needed.

In Eclipse, Run->Debug Configurations->Remote Java Application
Create a new Debug Configuration, make sure host as localhost, and port as 7777, also attach source.

How to debug Java code originated by ANT script in Eclipse

Need add the followings to the ant target that you are intended to debug.

   
      
      
       ...
    

When you run this target, it will say "[java] Listening for transport dt_socket at address: 5432", and stop here for you to debug.
You need go to Run->Debug Configurations->Remote Java Application
Create a new Debug Configuration

Host: localhost
Port: 5432

Also attach source.

If you run it, it will go to the debugging point.

How do you undo clicking Never Save Password in Chrome?

I really like Chrome's "Save Password" function, saving me a lot of time typing. But sometimes, if I accidently check "Never for this site", I will lost the capability. The question is how could I get it back? 

chrome://chrome/settings/

Click "Manage saved passwords".

In the bottom, you will see "Never Save" list, just delete the entry you would like to save the password.

Notepad++ Plugins

XML Tools: Pretty Print

Oracle date related SQL queries

select TO_DATE(sysdate, 'dd/mm/yyyy') from dual

select TO_CHAR(sysdate, 'MM/DD/YYYY') from dual;

select sysdate from dual;

select * from myTable where DTTMCREATED BETWEEN TO_DATE('09/20/2012','mm/dd/yyyy') AND TO_DATE('09/21/2012','mm/dd/yyyy') 

/* as it's case insensitive in sql, so MM==mm
Oracle use mi to replace mm, and hh24 to represent use 24 hours format. */


Oracle: managing password

After a while, oracle user password will expire:

login in as system
select username, account_status from dba_users;
alter user HAIBO_JPMC identified by my_pass;

Philosophy of Guice

Dependencies injection + interfaces

Classes are glued together by interfaces, and implemented classes are injected in run-time.
---Compile time: interface calls interface, run time: implementation calls implementation. In between taken care by Guice.
  • we don't need implemented classes to get compiled.
  • we could change to different implemented classes on the fly.
  • No need to rewrite test client.
Guice
  • What to inject: map interface to real implementation, this is the place we'll make the change. Keep mind, bind interface to implementation is the best practice, but you could also bind any class to its sub class, as long as they are the same type or implements the same interface.
public class BillingModule extends AbstractModule
{
  @Override 
  protected void configure()
  {
    bind(TransactionLog.class).to(DatabaseTransactionLog.class);
    bind(CreditCardProcessor.class).to(PaypalCreditCardProcessor.class);
    bind(BillingService.class).to(RealBillingService.class);
  }
}
  • Where to inject: mark the location to tell Guice where to replace interface with implementation
public class RealBillingService implements BillingService 
{
  private final CreditCardProcessor processor;
  private final TransactionLog transactionLog;

  @Inject
  public RealBillingService(CreditCardProcessor processor, TransactionLog transactionLog) 
  {
    this.processor = processor;
    this.transactionLog = transactionLog;
  }
....
}
  • How to inject: Usage of Guice, create injector based on module, injector is like a map.
public static void main(String[] args) 
{
    Injector injector = Guice.createInjector(new BillingModule());
    BillingService billingService = injector.getInstance(BillingService.class);
    ...
}

Invoke Method

ResultSet rs....
int index ...

Object obj = rs.getObject(index);
obj = rs.getTimestamp(index);
//this will throws exception "oracle.sql.TIMESTAMP cannot be cast to java.sql.Timestamp"

To solve this problem:


Class clz = obj.getClass();
Method method = clz.getMethod("timestampValue", null);
obj = (Timestamp) method.invoke(obj, null);

Flex Object

setter:
var obj:Object = new Object();
obj.name="test";

getter:
var name:String = obj[name];

Why can't we just call obj.name to get the value? You could only if you could directly use the property name onto the object. You could not do like the following:

var key:String = "name";
var nameValue=obj.key; //this will not work
var nameValue2=obj.name; //this will work

The only way you could do is through []

var nameValue3=obj[key]; //this will work, and recommended

We could actually take property_name == ["property_name"].

Conversion between Java object and Flex object:

Objects are serialized using Java bean introspection rules and also include public fields. Fields that are static, transient, or nonpublic, as well as bean properties that are nonpublic or static, are excluded.

So only public-non-static fields will be transferred to Flex object.

XStream Notes


  • If the java class the XStream using is an inner class, you will find something like Outer-class in the xml,  better don't use inner class for XStream.
  • If you have a filed called "children" which is a list of object, but you don't want to show the name of "children", you want only show the list of object directly, you could doxs.addImplicitCollection(Node.class, "children"); in this way, "children" will not show up in xml file.
  • If you want one attribute name showed in side the tag, using xs.useAttributeFor(Employee.class, "name");
  • <employee>
  •     <name>Jack</name>
  •     <role>Manager</role>
  •     <department>Finance</department>
  •   </employee>
  • to 
  • <employee name="Jack">
  •     <role>Manager</role>
  •     <department>Finance</department>
  •   </employee>

How To Import/Export Environment Variables

Use RegEdit to import/Export

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment HKEY_CURRENT_USER\Environment

What is the difference between :ssh: and :ext:?

Both these protocols normally use the SSH (Secure Shell) protocol to communicate with the CVS server, meaning that your passwords and data are safe from eavesdroppers (although :ext: can be configured to use other protocols as well).

The difference is that :ssh: uses an SSH client built into CVSNT, while :ext: relies on an external SSH client. If you use CVS from the command line, :ssh: has the advantage that you do not need any other software. Since TortoiseCVS already comes with its own SSH client, there is nothing gained from preferring :ssh:. Additionally, at least some versions of CVSNT have problems communicating with non-CVSNT servers, such as those used on the majority of UNIX servers.

Another important point is that it is not possible to configure :ssh: to use another port etc. in the Preferences dialog of TortoiseCVS. That dialog applies only to :ext:. Therefore, we recommend that you always use :ext: instead of :ssh:.

How do I tell if my computer can run a 64-bit version of Windows?

How do I tell if my computer can run a 64-bit version of Windows?

To run a 64-bit version of Windows, your computer must have a 64-bit-capable processor. To find out if your processor is 64-bit-capable, do the following:
  1. Open Performance Information and Tools by clicking the Start button Picture of the Start button, clickingControl Panel, clicking System and Maintenance, and then clickingPerformance Information and Tools.
  2. Click View and print details.
  3. In the System section, you can see what type of operating system you're currently running under System type. Under 64-bit capable, you can see whether you can run a 64-bit version of Windows. (If your computer is already running a 64-bit version of Windows, you won't see the 64-bit capable listing.)

How to make a bootable Windows 7 USB installer with CMD:

How to make a bootable Windows 7 USB installer with CMD:
  1. Open and run CMD as Administrator.
  2. Type Diskpart, press Enter.
  3. Type List Disk, press Enter.
  4. Type Select Disk # (where # is the number your USB drive shows up as), press Enter.
  5. Type Clean, press Enter.
  6. Type Create Partition Primary, press Enter.
  7. Type Active, press Enter.
  8. Type Format Quick FS=FAT32, press Enter.
  9. Type Assign, press Enter.
  10. Type Exit, press Enter.
  11. Copy everything from the Windows 7 installation DVD onto the USB key (a simple drag and drop will do; if you have an .iso extract or mount first).

ThinkPad T400S, hit F1 enter BIOS.

Make sure put USB HDD as the first priority of start up.

Base 64 Encoidng and Decoding

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import org.apache.commons.codec.binary.Base64;

String strTobeEncoded = "This is message body which will be 64 encoded";
String strTobeDecoded = "VGhpcyBpcyBtZXNzYWdlIGJvZHkgd2hpY2ggd2lsbCBiZSA2NCBlbmNvZGVk";

String encodedResult = "";
String decodedResult = "";

try
{
 // encoding using sun.misc.BASE64Encoder;
 BASE64Encoder encoder = new BASE64Encoder();
 encodedResult = encoder.encode(strTobeEncoded.getBytes());
 System.out.println("Encoded by Sun's encoder: " + encodedResult);

 // decoding using sun.misc.BASE64Encoder;
 BASE64Decoder decoder = new BASE64Decoder();
 decodedResult = new String(decoder.decodeBuffer(strTobeDecoded));
 System.out.println("Decoded by Sun's decoder: " + decodedResult);

 // encoding using org.apache.commons.codec.binary.Base64;
 encodedResult = new String(Base64.encodeBase64(strTobeEncoded.getBytes()));
 System.out.println("Encoded by Apache's encoder: " + encodedResult);

 // encoding using org.apache.commons.codec.binary.Base64;
 decodedResult = new String(Base64.decodeBase64(strTobeDecoded.getBytes()));
 System.out.println("Decoded by Apache's decoder: " + decodedResult);
}
catch (Exception e)
{
}

Target runtime SpringSource tc Server Developer Edition (Runtime) v2.1 is not defined.

Solutions:

1. Delete the server
2. Recreate the server: create new instance, choose template insight.
3. Right click the project, find "Targeted Runtimes", removed the old one.

Eclipse SSH and extssh

A couple of days ago, I found I could not use Tortoise CVS to work with CVS repository, after I replacing all "extssh" with "ext" in all Root, it's working.

Today, I found Eclipse is not working with CVS repository, and here is the fix:

Preferences->Team->CVS->Ext connection Method->Choose "Use another connection method type to connect", and select Connection type as "extssh".

Using DropBox to Host Your Code

I wrote some Flex applications, and would like to post them into my Blog. First, I tried to use Google Docs, there is no problem to upload the folder, but Google Docs seems not let you have the link to the file. Then I tried DropBox's Public folder, wow, it's unbelievably easy, just drag and drop the release version of the Flex application to Public folder, then select the main html file, and right click, DropBox->Copy Public Link, now you have the web link to that file.

Next, just copy the following to my blog, and I am all set.

EZFixedFormatReader

Get Lapsed Time in Java

long startTime = System.currentTimeMillis();
System.out.println("start getting super session: " + startTime);

long endTime = System.currentTimeMillis();
System.out.println("end getting super session: " + endTime);
System.out.println("time taken in seconds: " + (endTime - startTime)/1000);
System.out.println("time taken in mill seconds: " + (endTime - startTime));

SimpleDateFormat


LetterDate or Time ComponentPresentationExamples
GEra designatorTextAD
yYearYear199696
MMonth in yearMonthJulyJul07
wWeek in yearNumber27
WWeek in monthNumber2
DDay in yearNumber189
dDay in monthNumber10
FDay of week in monthNumber2
EDay in weekTextTuesdayTue
aAm/pm markerTextPM
HHour in day (0-23)Number0
kHour in day (1-24)Number24
KHour in am/pm (0-11)Number0
hHour in am/pm (1-12)Number12
mMinute in hourNumber30
sSecond in minuteNumber55
SMillisecondNumber978
zTime zoneGeneral time zonePacific Standard TimePSTGMT-08:00
ZTime zoneRFC 822 time zone-0800

must override a superclass method

I just did an update from Mercurial, and I found one of the class having compilation error on one of the method.

XXXXX must override a superclass method

I do notice that method has an annotation called "@Override". A quick search, I found that's because my Eclipse's compilation level is set as 1.5.

Preferences->Java->Compiler
Make sure Compiler compliance level set as 1.6

DropBox + Mercurial: A perfect solution for code development

Ever had the problem copying codes over from one machine to another, most likely, home vs work? DropBox solved the problem syncing the codes between different machines, while Mercurial (without Push) provides version control abilities.

Changes between different Java JDK

Last week, one of my colleague told me that there is some compilation error in his project, while I checked mine, I have no problem, then quickly I found the problem: I am using JDK 1.6, while he is using 1.5. The culprit is a method from String class isEmpty(), which is a total new method at JDK 1.6, this incident prompts me to think if there is way to quickly find out the changes between different JDK.

I found this link , which shows differences between between 5.0 fcs and 6 Beta.

1.6
1.7

DBVisualizer

I just found something that I didn't know about DBVisualizer

 1. For selected table, we could sort the order of columns by clicking "Grid Column Chooser", and we could also customized which columns to be visible or not. And the customized columns will be kept until we close DBVisualizer, it would be really nice if the customized columns could be saved even if we close the application.

2. DBVisualizer also provides type as search function in many aspects.

3. We could also filter on table name in DBVisualizer, but it would be really nice if this is could be done by type as search.

Get current user name in Flex

package
{
    import flash.filesystem.File;

    public class UserUtil
    {
        public static function get currentOSUser():String
        {
            var userDir:String = File.userDirectory.nativePath;
            var userName:String = userDir.substr(userDir.lastIndexOf(File.separator) + 1);
            return userName;
        }
    }
}

Get current user name and machine name in Java

    System.out.println(System.getProperty("user.name"));
    java.net.InetAddress localMachine = java.net.InetAddress.getLocalHost();
    System.out.println(localMachine.getHostName());

Cannot load 64-bit SWT libraries on 32-bit JVM in Eclipse

Let's end this once for all.

You got this problem is because you are using 64bits Eclipse, but your ant target is using 32bit JDK.

It's OK to use 32bit JDK in Eclipse, but you'll have problem when your ant need some GUI prompt, at this point, it will call Eclipse to generate this GUI prompt which is 64 bits, and now we'll have problem.

Solutions:
1. Use 32bit Eclipse
2. For those ant targets which require GUI prompt, change JRE to 64bits JDK.

XStream Notes

Using xstream-1.4.2.jar, and got the following problem:

Exception in thread "main" java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException
at com.thoughtworks.xstream.XStream.<init>(XStream.java:336)
at com.hempire.xstream.Writer.main(Writer.java:22)

The XML Pull Parser API defines an own mechanism to load the factory for the available XPP (XML Pull Parser) implementation. XStream's XppDriver never used this lookup mechanism automatically before version 1.4, now it will. Therefore you will have to add a dependency to xmlpull if the XPP implementation does not deliver the classes on its own. This dependency is necessary for Xpp3 in contrast to kXML2 that contains the classes. Use the Xpp3Driver or the KXml2Driver if you want to select one of the directly supported XPP implementation on your own without using the XPP factory. Note, that the minimal version of kXML2 does not support the XPP factory, but can be used by the KXml2Driver.

I honestly don't understand what the above means, but the bottom line is if we include any of the following jars, you should be fine:

kxml2-2.3.0.jar
kxml2-min-2.3.0.jar
xmlpull-1.1.3.1.jar
xpp3_min-1.1.4c.jar

kXML2 is recommend for use as it will greatly improve the performance of XStream.

Supported XML parsers and packages:

Get to Jira (or any web) quick from cygwin

1. Put the following in .bashrc:
export jira="https://jira.dovetail.net/browse/BUG-"
2. Make it effective:
source .bashrc
3. under /home/hliu/bin,  create file named as "jira":
cygstart "$jira$1"
4. Make it executable:
dos2unix jira
chmod 755 jira
5. Now from cygwin, you could type:

How to put codes nicely in Blog Using SyntaxHighlighter

Link

Change template is one time thing. After that, whenever you need put codes into blog, in HTML mode, put codes between

<pre class="brush:java"> ... </pre>

<script type="syntaxhighlighter" class="brush:xml">
</script>

You have the option to change the type of language, just as we are using java here, here is the list of the supported languages.

class='brush:java'
class='brush:as3'   //action script 3
class='brush:bash'
class='brush:css'
class='brush:groovy'
class='brush:js'    //java script
class='brush:py'
class='brush:sql'
class='brush:xml' //xml, xslt, html

My Template: add before </head>

Faster Copy Files

 
public static void copyFile(File sourceFile, File destFile) throws IOException 
{
  if (!destFile.exists()) 
  {
    destFile.createNewFile();
  }

  FileChannel source = null;
  FileChannel destination = null;
  try 
  {
    source = new FileInputStream(sourceFile).getChannel();
    destination = new FileOutputStream(destFile).getChannel();
    destination.transferFrom(source, 0, source.size());
  } 
  finally 
  {
    if (source != null) 
    {
      source.close();
    }
    if (destination != null) 
    {
      destination.close();
    }
  }
}
    
Link

XStream

http://xstream.codehaus.org/
http://www.ibm.com/developerworks/xml/library/x-xstream/
Library of serializing object to XML and deserializing object back from XML
1) Example of converting a list of object into a XML file:
public boolean XStream2XML(List importEntryList, String strOutXMLFilePath) 
{
  XStream xs = new XStream();

  //by default, xstream will use class's full name
  //you could use alias to avoid that
  xs.alias("entryList", List.class);
  xs.alias("importentry", ImportEntry.class);
  xs.alias("attribute", Attribute.class);

  try 
  {
    FileOutputStream fs = new FileOutputStream(strOutXMLFilePath);
    xs.toXML(importEntryList, fs);
    //a simpler version
    //String xml = xs.toXML(importEntryList);
    fs.close();
  } 
  catch (Exception e1) 
  {
    //e1.printStackTrace();
    return false;
  }

  return true;
}
2) Example of converting XML back to Java Object
String xml = "......";
Person newJoe = (Person)xstream.fromXML(xml);

Create Symbolic Link

ln -s source_file link_name

Java Preferences

Here is the situation, you want to save some user preferences, for example, I like certain columns for a given table, I don't want to customize it every time, I'd like to save it. Originally, I thought I might need a configuration file to achieve this, but soon I realize that it would be a pain, first of all, where to put this file? if my application is achieved, I don't even have the access the application folder. Secondly, every time I update the file, I need search this file and remove the old entry. I think there got to be a better way to do this.

Link
Link

In windows, it's stored under
HKEY_CURRENT_USER\Software\JavaSoft\Prefs

Just so we know, that we could import and export part of Registry, in this way, if we change our machine, we could just export/import and go.

Back up your precious data

Robocopy "C:\Documents" "E:\Back Up\My Documents" /E /V /PURGE /R:5 /W:15

How To Install SSD

Needless to say, SSD is the man at the moment. Let's get down to how to install and transfer your OS.

1. First decision you need make is: install OS fresh or migrate your current system. Install OS refresh is really easy but time consuming, here I take migration path.
2. Back up the data that you don't want to loose. In general, it's pretty safe to migrate your OS to SSD, but you have to prepare for the worst.
3. You might want to clean up your system to save spaces, besides the spaces that your current system takes should be smaller than your SSD size. try Defraggler and CCleaner.
4. Update Chipset Drivers. AMD or Intel
5. Shutdown your PC and install SSD, should be very easy: SATA data cable and SATA power cable.
6. Restart PC, going into BIOS, make sure your IDE is in IACH mode, usually it should be already.
7. Go to buy Paragon Migrate OS to SSD 2.0, it's $20, yes, there are plenty of free ways to do it, but I just find it's worth it to spend $20 to save all the troubles.
8. Run this program, and copy your current system to SSD, it will take less than 10 minutes.
9. Shutdown pc, unplug in your old hard drive, and make sure your SSD is the first choice of starting option.
10. Restart PC, you should have the exactly same system, just much faster now.

After you are done that, there are a lot of stuff that you could do or not to do, here are the lists:

Connect video card to TV with HDMI

I got a GeForce 9800 GT video card, and I connected it with my HDTV with HDMI cable, everything works with except no audio.

The problem is 9800 GT itself only transfer video over HDMI, if we want to audio also transfer over HDMI, we need use Internal S/PDIF Digital Audio Cable to connect mother board with video card.
This is the cable. My mother board actually does support S/PDIF output, so just connect the white side of the cable to video card, and the black side to mother board S/PDIF output connection header, something like
You need check your mother board manual to make sure which port is which port, and make sure SPDIF port to SPDIF and GND to ground.

Now pull off your other audio attachment to PC, and restart the computer, you should have audio over HDMI now.

loading log4j.properties

String resource = "/log4j.properties"; // / is necessary
URL configFileResource = Log4JTest.class.getResource(resource);
PropertyConfigurator.configure(configFileResource);

log4j.properties

#default one
log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender

log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%p [%t] %c{2} (%M:%L) - %m%n


#under package example
log4j.logger.example=INFO, A2

log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.File=${user.home}/test.txt

log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%5r %-5p [%t] %c{2} - %m%n

Init with Array or ArrayCollection

I am trying to use repeater to create a set of checkbox, at first, I am trying to use Array as repeater's data provider. If the array is hard coded, it works, but if I initialized the data for the array in init() method, it will not work. I changed the array to array collection, and it magically works!!!

That's quite strange...

Flex Style Explorer

http://examples.adobe.com/flex3/consulting/styleexplorer/Flex3StyleExplorer.html#

Install Flash Builder as a plugin for Eclipse

Link

  1. Install Flash Builder standalone
  2. Navigate to the installed Flash Builder installation location and open the utilities folder.
  3. Run the executable Adobe Flash Builder 4.6 Plug-in Utility.exe.
  4. Select the language and click on OK.
  5. Select the Flash Builder installation location if prompted.
  6. Select the Eclipse folder into which you want Flash Builder 4.6 to be plugged into and click Next. (Note: Your copy of Eclipse must be version 3.6/3.6.1/3.6.2/3.7, 32-bit and must contain a folder named “dropins”, even though your FB 4.6 is 64 bits)
  7. Review the pre-Installation summary and click on Install
  8. Following installation, it is recommended that you edit the eclipse.ini file for your Eclipse instance, so that it includes the following settings: 
-vmargs -Xms256m -Xmx512m -XX:MaxPermSize=256m -XX:PermSize=64m 

Get key/value from Flex Object

Ok, so we got a Flex object, let's suppose it's a map object, how could we retrieve the key/value from it?
//retrieve keys
for (var key:String in obj) 
{
   trace(key);
}

//retrieve values
for each(var value:String in obj) 
{
   trace(value);
}

The for..in loop iterates through the properties of an object, or the elements of an array. For example, you can use a for..in loop to iterate through the properties of a generic object (object properties are not kept in any particular order, so properties may appear in a seemingly random order):

The for each..in loop iterates through the items of a collection, which can be tags in an XML or XMLList object, the values held by object properties, or the elements of an array. For example, as the following excerpt shows, you can use a for each..in loop to iterate through the properties of a generic object, but unlike the for..in loop, the iterator variable in a for each..in loop contains the value held by the property instead of the name of the property:

Print out object in Flex

In Flex, object could be a lot of things, check here, you can see a flex object could be a Java map or dictionary. To check out its content could be really desirable, here is a useful function:
import mx.utils.ObjectUtil;

trace(ObjectUtil.toString(obj));
This will print out the content of the object very neatly.

Debugger Version of Flash Player + trace()

Recently I am working on a Flex project, and found that trace() is not working. Trace() method is equivalent of System.out.println() at Java, without making it work, it's a huge blow to debug on Flex. After some search, here are my foundings:

1. You need make sure your web browser has a debugger version of Flash Player.
Go to here, if you see "Debugger version of Flash Player", congratulations, otherwise, you need go to here to download a debugger version, be aware that Chrome has a build-in flash player, but it's not a debugger version, I have not figured out how to install a debugger version in Chrome yet, but here is a link which might help.
2. You need run your web server in debug mode.
3. You need invoke the web application from Eclipse's debug mode.

After that, trace() will print out whatever you want to see beautifully in your console.

---Update:
Sometimes, you need uninstall your current non-debugger version first before installing debugger version:

http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-windows.html

Create war file for Flex/Java project

SpringSource Tool Suite
File->Export->Web (War File)