Monday, November 22, 2010

[Java] What will be printed to a console?

ArrayList<Integer> list = new ArrayList<Integer>();
list.add(1);
list.add(2);
list.add(3);
list.remove(1);
System.out.println(list);

Thursday, November 18, 2010

Note for starting new Eclipse workspace

  • Import Formatter.
  • Customize Save Actions.
  • Set text editor "spaces for tabs" and "displayed tab width".
  • For MacOSX, change "Content Assist" short-key.
  • Set content assist to help import favorite static members.

Monday, November 1, 2010

[Java] Jars inside Jar

Jar that contains multiple jars inside is not support directly by Java. There are some workarounds on this.
  • Put jars in to jar as ordinary files then load them with your own customized classloader. There is a tool such as One-JAR™ but some people told that it causes performance problem (I have not try this).
  • Extract jars to .class and pack them together to a single jar. You can archive this easily with Ant's Zip Task
For me, I choose the second approach. There are more workarounds in reference links below.

Java: Easiest way to merge a release into one jar-file
Is it possible to package all the jar dependencies in one big jar ?

Config number of file descriptors on Linux

Check file descriptor limit for a process. Vary depending on owner of the process $ cat /proc/{process-id}/limits Check current number of...