26 Apr 2012, 9:58am
gwt java:

leave a comment




  • Multiple Projects and GWT

    When work­ing on sev­eral large scale projects (in Eclipse), it’s con­ve­nient and of course more effi­cient to share and reuse code via com­mon libraries. While those are in an early stage they need to be changed a lot and there­fore it’s handy to link projects in instead of cre­at­ing new jars each time the library has been updated.
    Unfor­tu­nately, this stan­dard approach for Java devel­op­ment in Eclipse does not work that straight for­ward as with plain old Java projects, it requires three steps in total:

    1. Link the library project to all rel­e­vant projects (“Project Pref­er­ences” -> “Java Build Path” -> “Projects” -> “Add…”)
    2. Then, add the client-side code of the library (by adding it as a mod­ule.) There­fore, edit the gwt.xml of your appli­ca­tion and add for exam­ple <inherits name="net.svenbuschbeck.gwt.lib.SuperLib "/> where Super­Lib is the file name of the gwt.xml file in you library project and before that is the pack­age it lies in.
    3. Add the code to the project by link­ing a source folder. Unfor­tu­nately, this is required if you do not want to write an Ant script to com­pile your appli­ca­tion. (If you pre­fer Ant check this out) I don’t like the idea of using such a script because if you for­get to run it each time you make changes, you will end up in confusion—let’s go for the con­ve­nient, auto­matic way then.
      1. Add a folder to your appli­ca­tion project; open the “advanced” sec­tion in the folder cre­ation dia­log, select “Link to alter­nate loca­tion” and pick the source folder (usu­ally “src”) of your library project. (Hint: if you work within a team using a ver­sion­ing sys­tem, you can cre­ate a vari­able for that folder and use this instead. This way, each of your col­leagues can put the library project in a dif­fer­ent folder and accom­mo­date for that by adjust­ing the vari­able :) )
      2. Right click the folder, “Build Path” -> “Use as Source Folder”. Done.

    Sur­pris­ingly, the GWT plu­gin for Eclipse does not honor the project link­ing, thus all the ref­er­ences need to be made explicit or you will end up with lots of the fol­low­ing: ClassNotFoundException.

    28 Feb 2011, 11:10pm
    gwt java:

    leave a comment




  • How to Execute Code When the GWT Application Is Going Down

    My goal was to store the UI state of my appli­ca­tion just before it gets ter­mi­nated to be able to restore it next time the way the user left it the other day.

    I tried to add an addAttachHandler to the RootPanel to get informed about the root panel get­ting detached from the DOM so that I can final­ize my appli­ca­tion. Sur­pris­ingly, that does not work in Chrome (tested Chrome and Fire­fox only).

    But besides that this sounds like a bug to me, I found the “proper” way of doing things before the appli­ca­tion ends:

    Window.addWindowClosingHandler(new Window.ClosingHandler() {
    	@Override public void onWindowClosing(ClosingEvent event) { ... }
    });

    In the end, I think some­thing like Document.addUnloadHandler would be more sug­ges­tive… clos­ing the win­dow or reload­ing a page is both exit­ing the appli­ca­tion by unload­ing the DOM — not clos­ing the window.

    7 Feb 2011, 2:58pm
    java:

    leave a comment




  • Java Cookies from the Future Past

    While work­ing with cook­ies in Java/GWT and thus—to set the expire date—with Date, I found a doubt­ful Java behavior.

    My goal was to set a cookie to expire in about one month from today like this:

    Date expires = new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 30);
    Cookies.setCookie("myCookie", "myData", expires);

    And kept won­der­ing why the cookie never got stored.

    And finally cre­ated a sim­ple test case like this:

    Date today = new Date();
    Date tomorrow = new Date(today.getTime() + 1000 * 60 * 60 * 24);
    Date nextMonth = new Date(today.getTime() + 1000 * 60 * 60 * 24 * 30);

    And got fol­low­ing dates:

    today=Mon Feb 07 14:27:50 CET 2011
    tomorrow=Tue Feb 08 14:27:50 CET 2011
    nextMonth=Tue Jan 18 21:25:02 CET 2011

    Accord­ing to Java’s cal­cu­la­tion, the cookie was expired already before even being set.

    Took me a bit to under­stand why:
    1000 * 60 * 60 * 24 * 30 = 2,592,000,000 = 0x9A7EC800
    Thus, the first bit got set to one… a clas­si­cal over­flow caus­ing the inte­ger value to become neg­a­tive — just try:

    System.out.println(1000 * 60 * 60 * 24 * 30);

    It will print out -1702967296.

    Fix: Add a lit­tle L will solve the issue by forc­ing the com­piler to cal­cu­late using the scope of long:

    Date nextMonthLong = new Date(today.getTime() + 1000L * 60 * 60 * 24 * 30);

    I guess I will fall for that one again some­time as the error is not obvi­ous in my opin­ion — espe­cially because getTime() returns a long and still, the com­piler sticks with an int for the mul­ti­pli­ca­tion part.

    4 Feb 2011, 10:10pm
    gwt:

    leave a comment




  • Disable Context Menu in GWT

    To make use of the right mouse but­ton, it is nec­es­sary to dis­able the native browser con­text menu (the popup menu appear­ing on right click). This can be achieved like this:

    RootLayoutPanel.get().addDomHandler(new ContextMenuHandler() {
    
    	@Override public void onContextMenu(ContextMenuEvent event) {
    		event.preventDefault();
    		event.stopPropagation();
    	}
    }, ContextMenuEvent.getType());

    Same should work for RootPanel.

    After that, it is pos­si­ble to make use of the right mouse but­ton for exam­ple like this:

    someWidget.addDomHandler(new MouseMoveHandler() {
    
    	@Override public void onMouseMove(MouseMoveEvent event) {
    		if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
    		...
    2 Feb 2011, 11:41pm
    java projects:

    leave a comment




  • Authentication with FlickrJ

    When you know about user­name and pass­word logins, the whole Flickr authen­ti­ca­tion process for web appli­ca­tions seems a lit­tle weird on first sight, nev­er­the­less it is log­i­cal and nec­es­sary after you have done some read­ing (for exam­ple the offi­cial Flickr WebApp Auth HowTo).
    To get started and into cod­ing quickly (using FlickrJ and Java) I rec­om­mend this page. Espe­cially the code exam­ple is excel­lent in my opin­ion! Thanks Andy Sacher!

    17 Jan 2011, 6:38pm
    gwt jobs:

    leave a comment




  • Testing GWT Application in Virtual Machine

    I am devel­op­ing on a Mac, but to test my GWT appli­ca­tions for cross-browser com­pat­i­bil­ity in Inter­net Explorer I need to use Win­dows, thus I got Win­dows 7 installed using Par­al­lels. Just by the way, to be able to test in dif­fer­ent Inter­net Explorer ver­sion, I am using a pretty handy appli­ca­tion called IETester.
    But try­ing to access local­host with IE in the vir­tual machine did not work. I got a “404 page not found” error instead of see­ing my app run­ning on the local App Engine instance. Obvi­ously, Par­al­lels does not auto­mat­i­cally for­ward local­host requests to OSX and maybe that is actu­ally a good idea security-wise.
    To fix the issue, you need to run Google App Engine on a pub­lic net­work inter­face, or in other words, bind the App Engine server to all avail­able IP addresses. The down side: every­body know­ing your IP address can see the GWT app now, but oth­er­wise you are not allowed to access it in the viru­tal machine as from your OSX’s point of view, that Win­dows machine is “some other guy access­ing from the out­side”, too. To make GAE acces­si­ble from the out­side, add the para­me­ter “-bindAd­dress 0.0.0.0″ when launch­ing you local GAE. Using Eclipse you can achieve that by right click­ing your project -> Run As -> Run Con­fig­u­ra­tions -> Choose “(x)= Argu­ments” tab; add the option to the top most box titled “Pro­gram argu­ments” in the options area (e.g. before “-port 8888″).

    The first part of the list of argu­ments should look some­thing like that:

    -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -startupUrl GlocalUiPg2.html -logLevel INFO -codeServerPort 9997 -bindAddress 0.0.0.0 -port 8888 ...

    Now, you can access you app using the OSX’s pub­lic IP address. (You can get to know your IP by hav­ing a look at the net­work pref­er­ences panel.) Launch­ing GAE from Eclipse, you will see a dif­fer­ent link (URL) in the “Devel­op­ment Mode” tab now, con­tain­ing the pub­lic IP already. Using that one in, say, your Fire­fox on Mac, it will ask you now whether you want to allow the debug­ger access. That is also due to the fact, that you are now using a pub­lic address, so it is not clear to your local debug server, whether that request came from the same com­puter or some­one else in the network.

    14 Dec 2010, 11:49am
    java:

    leave a comment




  • Casting collections in Java

    Assum­ing two classes A and B as

    class A {}
    class B extends A {}

    It is just log­i­cal that cast­ing B to A works fine:

    A anObjectOfClassA = new B();

    But when it comes to col­lec­tions of As and Bs, a strange phe­nom­e­non appears in Java:

    Collection<B> collectionOfBs = new LinkedList<B>();
    Collection<A> collectionOfAs = (Collection<A>)collectionOfBs; // this line does not compile!

    That is, though the col­lec­tion wrap­per (the java.util.Collection class) is the same and B extends A, cast­ing a col­lec­tion of objects of class B to a col­lec­tion of objects of class A throws an compile-time error.

    But it works using gener­ics (the whole class for the sake of com­plete­ness and reusability):

    import java.util.Collection;
    import java.util.LinkedList;
    
    public class CollectionCastingExample {
    
      class A {}
      class B extends A {}
    
      Collection<B> collectionOfBs = new LinkedList<B>();
    //  Collection<A> collectionOfAs = (Collection<A>)collectionOfBs;
    
      Collection<A> collectionOfAs = downCastCollection(collectionOfBs, A.class);
    
      /**
       * Casts a collection of objects of class B where B extends A to a collection of objects of class A.
       *
       * @param <T> Base class
       * @param collection Collection of objects of a class extending T
       * @param aClass Representation of T
       * @return Collection of objects of T casted from given collection of objects of a class extending T.
       */
      @SuppressWarnings("unchecked")
      public static <T> Collection<T> downCastCollection(Collection<? extends T> collection,
          Class<T> aClass) {
        return (Collection<T>) collection;
      }
    }

    Despite the fact that a @SuppressWarnings("unchecked") is required, it avoids iter­at­ing over the whole col­lec­tion of Bs and cast­ing each of them from B to A plus adding them to a new col­lec­tion of As.

    3 Dec 2010, 4:02pm
    gwt:

    leave a comment




  • Adding a New Service (GWT)

    Adding a new servlet/service to you GWT appli­ca­tion is quite straight for­ward, e.g. by copy­ing the exam­ple “greet­ingSer­vice” or cre­at­ing a new servlet. But it’s easy to over­look a required change/adjustment of your project’s con­fig­u­ra­tion and you might end up with an error mes­sage like “Blocked attempt to access inter­face ‘some.package.SomeService’, which is not imple­mented by ‘some.other.package.SomeOtherServiceImpl’; this is either mis­con­fig­u­ra­tion or a hack attempt”.

    Check list (some should be replaced with what­ever you want to call your new service):

    • Copy or cre­ate files:
      SomeService.java and SomeServiceAsync.java in client pack­age
      SomeServiceImpl.java in server pack­age + change imple­men­ta­tion state­ment to SomeSer­vice
    • Adjust web.xml:
      <servlet>
      	<servlet-name>someServlet</servlet-name>
      	<servlet-class>some.package.SomeServiceImpl</servlet-class>
      </servlet>
      <servlet-mapping>
      	<servlet-name>someServlet</servlet-name>
      	<url-pattern>/[copy base directory name from other service declaration]/some</url-pattern>
      </servlet-mapping>
    • Anno­tate inter­face SomeService.java:
      @RemoteServiceRelativePath("some")
    • Con­nect to your new ser­vice in the client:
      private final SomeServiceAsync someService = GWT.create(SomeService.class);

    Def­i­nitely some pos­si­bil­i­ties to make a mis­takes or miss some­thing here.

    8 May 2010, 11:25am
    linux:

    leave a comment




  • Resizing System or Home Partion

    A very con­ve­nient tool for cre­at­ing, mov­ing, and resiz­ing par­ti­tions is GParted. I use it for all my partition-changing-needs — it is really pow­er­ful and yet easy to use! :)

    But it is not pos­si­ble to resize sys­tem rel­e­vant par­ti­tions while the sys­tem is run­ning — makes sense, right? ;)

    But you can down­load GParted as LiveCD ISO file and burn it on a CD. After that, restart your com­puter with the CD in your drive and a small linux will start up directly from CD includ­ing GParted, thus allow­ing you to mod­ify any drive and par­ti­tion there is. :) Do all required changes, click the exit but­ton and you are done. In my case, the com­puter did not reboot auto­mat­i­cally, instead I ended up with a com­mand line inter­face — use the com­mand “sudo reboot” to restart the sys­tem your­self if that happens.

    And just by the way, GParted does also han­dle Win­dows par­ti­tions eas­ily — so there is no need to buy or “get” Par­ti­tion Magic from some­where. But never for­get to backup your data first.

    Yet another hint: GParted works most reli­able if you do one step at a time. So for exam­ple, there are par­ti­tions A and B (A is in front of B) and you wish to give some of the free space in A to B. You need to do fol­low­ing steps: Shrink A, move B left and finally grow B. From my expe­ri­ence, GParted works best if you really do all those steps sep­a­rately, apply each of then, and go for the next one if the last one fin­ished successfully.

    30 Apr 2010, 11:04pm
    linux:

    leave a comment




  • Flickering Screen After Upgrade to Kubuntu 10.04

    First of all, I was amazed how smoothly the upgrade went. (K)Ubuntu and I guess other dis­tri­b­u­tions as well have gone quite a far way to become plat­forms for every­body — with a lot of soft­ware but even more tools, helpers and auto­matic back­ground ser­vices — like the nice upgrade service.

    There was only one prob­lem I ran into and I want to share the solution.

    I am run­ning Kubuntu 10.04 (just upgraded today) on a Lenovo IBM ThinkPad R60 (Yes, one of those with both brands on them ;) ) with an ATI Radeon X1400 graph­ics device. But since upgraded, my dis­play started flick­er­ing — not per­ma­nently but unbearable.

    The solu­tion that worked for me (at least par­tially — see below — and this is of cause depend­ing on the graph­ics device type) was to install the pro­pri­etary ATI dri­vers. I know, it is not a good solu­tion, I do not like to use them nei­ther and if any­one out there is read­ing this with a bet­ter solu­tion in mind, let me know it!! :)
    Edit 2011-02-14: Added a new post with an addi­tional, alter­na­tive solu­tion here.

    So what you need to do is  to get your favorite pack­age man­age­ment tool (e.g. Synap­tic or KPack­ageKit) — just hit Alt+F2 and type “pack­age” and pick KPack­ageKit from the list (it will ask you for the super user pass­word). Then, search for “fglrx”. In KPack­ageKit, you will find a result titled “Video dri­ver for the ATI graph­ics accel­er­a­tor”, and some­thing below the title like “fglrx — 2:8.723.1-0ubuntu3” but the ver­sion num­ber should not mat­ter. Click the arrow to the right, hit “Apply” and after reboot­ing, every­thing should per­fectly with­out any configuration.

    Good luck. ;)

    Prob­lems noticed so far: The dri­ver causes “Seg­men­ta­tion Fault” error mes­sages, e.g. when try­ing to open up the dis­play set­tings. That’s ugly, I know. But you can read in sev­eral forum and blog posts, that the sup­port for the for­mer nicely work­ing dri­ver for the ATI X1400 has been dis­con­tin­ued since 10.04, hence, it’s just good luck that the fglrx works some­how — good to know *after* upgrad­ing, right. But still, the flick­er­ing was unbear­able for me, thus, I accept the issues for now. I will keep my eyes peeled hop­ing for a proper solu­tion in the future.

    26 Apr 2010, 9:34pm
    linux:

    leave a comment




  • Change hotkey of Kubuntu’s Quick Launch Tool KRunner

    First of all: I love those quick launch tools aka key­stroke launch­ers, they are real time savers — every­one should have one!

    [For those with­out a glue what a key­stroke launcher is:] It is THE tool for launch­ing any kind of soft­ware or even open­ing doc­u­ments. Instead of mov­ing your mouse to you appli­ca­tions menu, click it, search the pro­gram, move the mouse there, maybe pick a sub-folder, move mouse again and finally click — unless you acci­den­tally moved a lit­tle but to far and the menu close again, com­pletely. :( But it is easy to put an end to this (as described below). Instead of doing all that click­ing, you hit a spe­cial key com­bi­na­tion, by default [Alt] and [Space], this will make a small input box show up, now, you only enter the first let­ters of the pro­gram — e.g. “f” will do after a few uses to start Fire­fox (the pro­gram learned that you use it a lot). It might save only a few sec­onds each time, but the sum up and, hey, it is very con­ve­nient, too!

    So here is what you need to do:
    Mac OS: It is already built-in — Just hit Alt+Space and type the name of the pro­gram you want to start (or files or what­ever).
    Win­dows: Get/install Launchy and use it as explained above.
    Kubuntu: built-in as well, BUUUT you have to hit Alt+F2 instead.

    And there it is, some­thing that kept annoy­ing me about Kubuntu for quite a bit. I was hop­ing to get used to it but for what rea­son? Alt+F2 is really not handy com­pared to Alt+Space.
    Finally, based on this old forum post and a few adjust­ments to fit nowa­days Kubuntu, all you need to do is this:

    1. Go to “Set­tings” -> “Key­board and mouse”
    2. Select “Global Key­board Shortcuts”
    3. Pick from the select box “KDE com­po­nent” at the top “Run Com­mand Interface”
    4. Now, you can access “Run Com­mand” — Change it to what­ever you like :)
    28 Feb 2010, 2:05pm
    linux:

    leave a comment




  • Moving home to it’s own partion (Ubuntu)

    We are going to move all accounts includ­ing their per­sonal data on a dis­tinct par­ti­tion. This rec­om­mended in case of sys­tem fail­ure to not loose any data.
    I have no idea, why the Ubuntu instal­la­tion wiz­ard does not do this by default — it should!

    This post is based on an arti­cle in Ger­man — I will mainly trans­late it, strip some plush and add some stuff to make life eas­ier and to reduce the risk of data loss. But be aware: to per­form any of those fol­low­ing things, you will need super user rights and you should feel some­what comfy with using the com­mand line. And of course, it might be pos­si­ble in cir­cum­stances unfore­seen, that you lose all your per­sonal data — but there are a lot of backup steps included below.

    Here we go: (con­sole input or state­ments are writ­ten in ital­ics)

    1. Prepa­ra­tion
      1. Cre­ate a backup: rsync –avx –progress /home <your backup destination>
      2. If you do not have a free par­ti­tion yet, I rec­om­mend GParted to cre­ate one (use sudo apt-get install gparted). I rec­om­mend ext3 for com­pat­i­bil­ity issues — but if you use Linux only, you can go for ext4 (please change ext3 to ext4 in step 1.6 in case) — make sure your new par­ti­tion is big enough for your home folder! Try to remem­ber the size (get size: du –sh /home) of /home, you can use it later on to ver­ify your new home location.
      3. Get par­tion name sudo fdisk –l /dev/sda — e.g. /dev/sda7 — I will refer to this name as (name)
      4. Copy your cur­rent file sys­tem con­fig­u­ra­tion: sudo cp /etc/fstab /etc/fstab.new
      5. Get par­tion UUID of new par­ti­tion: sudo blkid — you will find a line about (name) stat­ing a UUID (quite a long hex string), I will refer to it as (uuid) — copy it.
      6. Edit /etc/fstab.new, add a new line at the end as fol­lows (the lay­out should fol­low pre­vi­ous lines — sim­ply copy one and adjust it):
        UUID=(UUID)  /home                ext3         defaults                    0  2
    2. Copy
      1. Sign off / Log out
      2. Switch to con­sole mode by press­ing Ctrl+Alt+F1
      3. Cre­ate a mount point for the new par­ti­tion: sudo mkdir /mnt/tmp
      4. Add par­tion: sudo mount (name) /mnt/tmp
      5. Copy home from the old loca­tion to the new par­ti­tion: sudo rsync –avx –progress /home/ /mnt/tmp
      • Test
          1. Mount copy of home as new home: sudo mount (name) /home
          2. Check size of home folder — should be the same as in step 1.: du –sh /home
          3. Check mount­ing worked: sudo mount| grep /home should print out some­thing like
            (name) on /home
          • Switch
              1. yet another home backup: sudo mv /home /home.bak
              2. cre­ate new home mount point: sudo mkdir /home
              3. cre­ate a backup of fstab: sudo mv /etc/fstab /etc/fstab.bak
              4. put updated ver­sion in place: sudo mv /etc/fstab.new /etc/fstab
              5. reboot and you should be done: sudo reboot

              Ok, that’s that. If every­thing works fine, you can delete the backup home sudo rm –rf /home.bak and the fstab backup sudo rm /etc/fstab.bak. Hope you found it use­ful and I did not put in a mis­take or typo. Gimme feed­back! :)

              5 Aug 2009, 1:12pm
              php:

              leave a comment




            • Simple redirection using PHP and HTML meta tag

              Some­thing every­one needs once in a while… maybe you moved a file on your server or you did not install word­press in the root folder of your web­server — like I did nei­ther ;) — a redi­rec­tion or for­ward­ing can be an easy answer.

              The script is rather sim­ple — it redi­rects in three ways to pro­vide a rea­son­able fall back if any of the auto­matic redi­rect­ing fails. To use it on your server, just enter the URL/address/file name/folder you would like the user to be redi­rected to in the sec­ond line of the page/script.

              Put the whole code and markup in a file with file exten­sion “.php”.
              In my case, every user end­ing up at “www.svenbuschbeck.net” should to be for­warded to “www.svenbuschbeck.net/wordpress/home”. So I adjusted the script below like “$url = ‘wordpress/home’”, named the file “index.php” and put it in the root folder. Done :) .
              <?php
              $url = 'put your URL between the parenthesis';
              header("Location: $url");
              ?>
              <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
              <html>
              <head>
              <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
              <meta http-equiv="refresh" content="0;url=<?php echo $url; ?>"/>
              <title>You will be redirected... </title>
              </head>
              <body>
              If you are not redirected automatically, please click <a href="<?php echo $url; ?>">here</a>.
              </body>
              </html>
              16 Apr 2009, 5:46pm
              jobs:

              3 comments




            • how to install memchached 1.2.2 from source

              I have installed an instance of mem­chached ver­sion 1.2.2 on one of our servers (Debian etch) today and to keep you from spend­ing a whole after­noon, see my everything-step-by-step instruc­tion below.

              Mem­chached is a dis­trib­uted hash map, which can be used for exam­ple to speed up any kind of web appli­ca­tion, see web­site for details. In our case, we want to use it as tem­po­rary data store. I will report about the expe­ri­ences in a lat­ter post.

              intro­duc­tion

              Always refer to this page for details, but I cre­ated a ver­sion with less text but includ­ing steps to really start from scratch.

              All lines start­ing with # are com­mand lines, i.e. you need to type into a linux shell.
              Out­put of any kind is always sur­rounded by ” even if it is mul­ti­line output.

              con­tent

              a. get libevent (needed to install mem­cached)
              b. get mem­cached and ver­ify instal­la­tion
              c. use and test mem­cached within Java with junit/ant

              a. installing libevent 1.3

              a.1. check for cur­rent ver­sion of libevent

              a.1a.

              Log in as root or get super user rights by call­ing su

              # updat­edb
              # locate libevent

              If there is out­put includ­ing “libevent1” and/or “libevent-1″ (ignore pack­age files like *.deb) -> a.1b, oth­er­wise a.2

              a.1b. remov­ing old libevent version

              # apt-get remove –purge libevent1
              # Y

              # updat­edb
              # locate libevent
              Should now return noth­ing or pack­age files only, i.e. you are ready for installation

              a.2. installing libevent 1.3

              a.2a down­load­ing and unpacking

              # cd /usr/local/src
              # wget http://monkey.org/~provos/libevent-1.3b.tar.gz
              # tar zxvf libevent-1.3b.tar.gz
              # cd libevent-1.3b

              a.2b. con­fig­ur­ing

              # ./configure
              check the out­put, if it con­tains some­thing like “con­fig­ure: error: no accept­able C com­piler found in $PATH” -> a.2c. oth­er­wise a.2d.

              a.2c. com­pil­ing

              # apt-get install gcc

              Redo a.2b.
              I got out­put like “C com­piler can­not cre­ate exe­cuta­bles”, read­ing file ‘config.log’ did not help me at all. Googling finally did, as I found a forum entry, point­ing out a miss­ing lib.
              So try this:

              # apt-get install libc-dev

              Redo a.2b.
              If that did  not solve it… sorry … google on, there is no sense in going on with­out solv­ing this issue. :-/

              a.2d. make it!

              # make && make install

              If you get some­thing like “-bash: make: com­mand not found” -> A.2e, oth­er­wise A.3.

              a.2e.

              # apt-get install make

              Redo a.2d.

              a.3. con­fig­u­ra­tion

              Press the Esc key as you read [esc] in the com­mands below.

              # vim /etc/ld.so.conf.d/libevent-i386.conf
              # i/usr/local/lib/[esc]:wq
              # ldconfig

              b. install mem­chached and ver­ify installation

              b.1. down­load, unpack and install memchached

              # cd /usr/local/src
              # wget http://danga.com/memcached/dist/memcached-1.2.2.tar.gz
              # tar zxvf memcached-1.2.2.tar.gz
              # cd memcached-1.2.2
              # ./configure
              # make && make install

              After installing gcc and libc-dev in sec­tion a, this one went eas­ily for me — if you skipped sec­tion a and run in prob­lems here, please install gcc and libc-dev (see a.2c).

              b.2. ver­ify instal­la­tion of memchached

              b.2a. start mem­chached server

              # mem­cached –u www-data –vv

              Out­put should end with line “<3 server lis­ten­ing”. Per­fect! :)

              b.2b test server

              I will refer to this shell in front of you as server shell below. Now, open another shell on the same machine, I will refer to it a client shell.

              # tel­net local­host 11211

              You should see some­thing like “<7 new client con­nec­tion” on the server shell, switch back to client shell.

              # set test1 1 10000 1
              # a

              You should see “STORED” on client shell and the two fol­low­ing lines on server shell
              ”<7 set test1 1 10000 1
              >7 STORED

              Per­fect!
              You did it, your mem­cached is up and run­ning :)

              c. mem­cached and Java

              I wrote a lit­tle test pack­age using a Java client library for mem­cached from here, together with junit and ant. You can down­load it to have a look how sim­ple using mem­cache is and to ver­ify your instal­la­tion with an included  junit test, auto­mated with an ant build file.