Tag: java
Asynchronous logging with log4j
by ricardoz on Nov.25, 2009, under Articles, Performance, Security
In case you are not doing it already, using asynchronous logging is generally a good idea. You don’t want your application to slow down if the server IO is a little behind flushing all that logging to the filesystem. By making it asynchronous your application can continue running without having to wait for the log lines to be written to their final destination.
My personal choice for Java logging is log4j, there are a lot of different frameworks (including Suns own logging API), but log4j works great and is extremely flexible.
(continue reading…)
View Androids emulator log from Eclipse
by ricardoz on Nov.19, 2009, under Android, Tips
Sounds like it should be quite straightforward, right? Well, it is, but for some reason it took me more than a few minutes (maybe I need to get more sleep :P). Anyway, to view Androids emulator log from Eclipse go to Window / Show View / Other… / Android / LogCat
Super simple AJAX for Java apps using JQuery and JSON
by ricardoz on Oct.28, 2009, under Articles, JavaScript, Web related
Back in April I wrote about Java to/from JSON serialization using XStream. After developing several AJAX applications using PHP and JQuery, I found that for a lot of scenarios a very simple approach is not only easy but very effective. In the case of PHP, you can effectively enable AJAX in your apps using jQuerys $.getJSON() and PHP json_encode().
I think we can use a very similar approach for Java web applications, enabling the use of AJAX through a very simple, elegant and extensible architecture, without the use of complex frameworks and extra configurations.
(continue reading…)
Building androids
by ricardoz on Sep.04, 2009, under Android
I’ve been trying out the Google Android platform, and I have to say I’m quite pleased with it. The bundled Java API and VM seem to work very well and the development tools (Eclipse plugin and SDK) work just fine.
You can tell a lot of thought has been put into the API and the proposed development “style”, and the tutorials and documentation are easy to follow and do not deviate to marketing and commercial stuff.
Anyway, stay tuned if you want to get into it, I will post an app to the marketplace soon enough.
Java application as a MS Windows service
by ricardoz on Jul.29, 2009, under Tips
It’s really annoying to run something interactively on MS Windows when you know deep inside it should be an OS Service. Doing this on a *nix system is quite simple (most of the times you just need to write a short shell script), but on MS Windows it’s not so easy.
(continue reading…)
Trying out Google Appengine – OTP generation app
by ricardoz on Jul.15, 2009, under Security, Web related
I decided to try out the new Java based version of Google Appengine. So i wrote a very simple web app that allows the user to generate one time passwords (OTP) using the HMAC-SHA1 algortihm (see OATH).
You can check it out at http://obovweb.appspot.com. As the name suggests its based on my obov library.
(continue reading…)
Using SSH or SFTP resources from a Java app
by ricardoz on May.22, 2009, under Security
There are many commercial SSH client libraries for Java, but it was hard to find a good open source one. Finally I stumbled upon SSHTools and I have to say it works wonderfully and the API is clean and simple.
(continue reading…)
Reload resource bundles on the fly, finally!
by ricardoz on May.13, 2009, under Tips
Ever since the very first time I used a properties file in Java I’ve wanted to be able to reload it upon a sysadmin request or some other circumstance without having to reload the whole application, reset the application server or use some dark proprietary Sun APIs. Well, finally in Java 1.6 we can do it!!
(continue reading…)
Fast collection look-ups
by ricardoz on Apr.30, 2009, under Performance, Tips
I recently had to load a bunch of objects into memory and then perform thousands of look-ups over that collection. Using the good old java.util.ArrayList just didn’t cut it, the contains() function is extremely slow (as you would guess of course since this implementation stores elements as they are inserted and without any aditional indexing structure).
(continue reading…)
Automatically serialize POJOs to and from JSON
by ricardoz on Apr.22, 2009, under JavaScript, Tips, Web related
The best tool I’ve found so far to serialize POJOs to JSON (and back again) is XStream, it’s automatic, simple and elegant, check it out.