Skip to main content

Posts

Showing posts from June, 2013

Tomcat and JVM

JVM is Java Virtual Machine, a memory space where classes (code) are loaded and objects (data) are shared. JVM is equivalent to an Operating System process. When you type java... in you command line you are executing an independent process that loads Java classes in memory, the base classes from Java and yours (from the .class files or .jar you indicate). Another java... command will load a different process with its own memory and will load classes by itself. Instance word confusion: when you say 'two instances of the same JVM'. It's usual to say instance of a JVM to a separate process, it is, to a loaded independent JVM. If you are saying: two process are running JVM 1.5, OK, it's the same JVM in the sense it's the same version but they are different processes, different 'instances', independent in all sense. Webapp confusion: A webapp (by example) is simply a bunch of classes and objects instantiated, attending some URL in a web server. You can start Tomc…

Eclipse Linked Source - The benefit of using it

In project, the developers might have to worked on different version of the project. For example, they might be working on version 10, and have to patch and test  version 9 or 8 as well.

The normal way of could  be create multiple eclipse projects and switch from one to one. The result is not that bad, you just need to  import the version into Eclipse and work on that.  Still, you have to bear with multiple projects in your eclipse and live with it.

I personally don't like that very much. With the Linked source function, you just need to edit the path of the source switch  from different version and test them. You don't have to do other things with eclipse any more. So, your Eclipse UI is clean now.

Upgrade Web Application support from IE8 to IE9

I got a task to investigate the IE 9 issue if we upgrade the system to from IE8. It's kinds of frustrated during the period. In the end, I am pretty happy I finished it.

IE 8 user the Quirks mode which  means not standard with the http://www.w3.org/standards/agents/browsers

IE 9 by default still using quirks mode, however, IE10 will use standard mode by default. So, it's good we test IE 9 in standard mode now to avoid the future issue with IE10.

Blog the knowledge for the reference of future project.

IE  8 vs IE 9(standard mode)
#1  createElement  method
IE 8 : will  support  the format like : .createElement("<span id='xx'>abc</span>");
IE 9 : you can only do with steps.  
        createElement("span"); .setAttribute("id","xx");

#2 getElementById method
<div name=”nameOfDiv”>     … </div>
In standards mode (IE9) the below code will not work anymore.
document.getElementById(“nameOfDiv”)  --- This will return nul…

Caching in Java with LRUMap

Forwarded from http://blog.riamaria.com/32/caching-in-java-with-lrumap/

So you want to cache recently used values? Well, there’s LRUMap for that!
LRU stands for Least Recently Used. LRUMap uses the LRU algorithm to delete the least recently used value in the map (presumably full) to make space for the newest entry.
You can use LRUMap through the Apache Commons Collections library. You can download the jar file here.
So, how do you instantiate this thing? You can use the default constructor, or you can define its maximum size in the constructor. Its default maximum size is 100.
Map<Object, Object> map = newLRUMap(); Map<Object, Object> map = newLRUMap(100); Beware: The LRUMap isn’t synchronized and thread safe. If you want to make it synchronized you can use java.util.Collections.synchronizedMap(Map) to wrap around the LRUMap and instantiate it like so…
Map<Object, Object> map = (Map<Object, Object>) Collections.synchronizedMap(newLRUMap()); Map<Object, Object>…