Skip to main content

Posts

Some useful Java libraries

Here is a video from Javazone, where some useful Java libraries are mentioned: 02:30 xbean-finder : Annotation finder in jars. 03:50 shrinkwrap: Can download artifacts from Maven repo. 05:50 zt-zip : zip file utils from Zeroturnaround. 07:25 Airline: command line parser helper. 10:30 really-executable-jars-maven-plugin: makes self-extracting jars. 12:00 jansi : colorized command line. 13:30 jmxutils : JMX beans by annotations. 15:00 Feign : HTTP helper / annotation lib. OkHttp is also mentioned. 17:20 Jerry / Lagarto : JQuery-style selectors in Java. 20:00 jchronic : converting English free-text to time. 21:40 assertj: fluent interface for asserts in unit tests. 23:10 vtte : very trivial template engine. 24:45 tape : a collection of queue-related classes for Android. 26:10 connector/mxj (GPL): mysql helper. 28:10 ness-pg-embedded: prostgresql helper. 29:10 slice: effective off-heap memory helper tool instead of ByteBuffers. 32:20 paranamer : named params in java fro...

SAX Parser truncation problems

Have you ever met with strange problems regarding SAX parser when textual content seems to be truncated? When it seems that the parser transmits only a fragment of the content which is inside an XML element. Maybe not. Maybe yes but haven't noticed. Parser reads blocks of stream and it may call characters method more than one times. Well, it's written in the Javadoc and it's quite logical. If I have a very long text content, it couldn't had been processed in one go. It has to be split into parts. So, rather than assigning the content to a simple string, use concatenation instead and evaluate the content on endElement . By the way, the magical number is 2048. The parser implementation typically uses this block size. Unfortunately it's a kind of thing which easily creeps under the radar of tests. Nobody writes tests for long data. See also this on Stackoverflow.

NoClassDefFoundError

Recently I faced with NoClassDefFoundError s during unit testing despite all class files were in place. It was quite strange. Furthermore this error happened only on our CI (Linux) server, I couldn't reproduce it on desktop, neither on Windows nor on Linux. I started to investigate the stack traces and it seemed that the native open method of the FileInputStream was failed. After more investigation by JProfiler I found, that many classLoader.getResourceAsStream invocation happens in our code, but those streams are never closed. Meanwhile I found this nice writing about Tuning Linux applications which says: "Some Linux applications; for example, a JVM, might require a higher file descriptor limit. If an application can't open files because the file descriptor limit has been exceeded, you might get a NoClassDefFoundError error message." Then it says how to increase number of file handlers ( ulimit -n 2048 ), but let's rather close the resources guys. It ...

Installing Firefox Java plugin on Ubuntu Linux for Dummies

As a Windows user, I was amused how not easy to install Java on Ubuntu Linux (10.04) nor installing Java (1.6) plugin into Firefox (3.6). It's not nearly a download-next-next-finish task. Additionally, digging into forums I found a lot outdated solutions which I tried and soon realized that they doubtlessly aren't working. Here is the one which worked for me: First, open a terminal window: Applications menu -> Accessories -> Terminal. Type the followings (you will be promted for admin password, because sudo prefix means you want to do something in the name of the super (or sytem) user): sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" sudo aptitude update sudo aptitude install sun-java6-jdk Then you have to select things with arrows and pressing enter. Then Timothy says in the forum you have to type this, but I didn't need it: sudo update-alternatives --config java Now you can check if java is installed by typing java -version . ...

Web-based chart libraries

Recently I was hunting for good web-based client-side chart-drawing libraries . I've found a number of blog entries or articles which enumerates some subset of existing frameworks and write sentences about them, like this: ' This is fancy, this is not so fancy but it's still good. ' Those writings didn't help me a lot. What I am interested in? Presentation model: Can be Flash, HTML Canvas or any other magic. This influences interoperability and scalability of the charts. Licensing model: Is it free, commercial or GPL. Dependencies: Should I have to bring another dependencies with the chart-drawing facility? Docs: quality of documentation. Examples: quality of examples. And finally, outlook of the charts and number of the options are also matters. I've found 16 libraries up to now and made an overall matrix about them, regarding considerations above. Check it out.

Brillien

There were three presentation as usual at the 14th Java User Meeting at Budapest yesterday, but this time I'll write only about the first one. Imre Fazekas had been invited from Debrecen to make a presentation about Brillien , their Java enterprise platform. It's an alternative way of modeling and implementing business logic in place of Java Enterprise (J2EE) Technology. It uses invasive programming model which means we have to extend classes from Brillien superclasses and we may use annotations. The whole system based on asynchronous XMPP communication and a set-context-flow concept. It's something like an application server, but uses a more logical and set-based approach. As the presenter said, it has very good speed and performance characteristics. Currently there are no IDE or other tools for editing models because this is a very young project, however a Maven plugin and a Maven archetype is accessible on the homepage. A very good introduction and tutorial can be also ...

Hacking Apache POI

In the near future, presumably, I'll have to read and process complex xlsx documents containing a lots of formulas. Jexcelapi can't even open those kinds documents, so I turned to Apache POI . Unfortunately, POI also have problems with some formulas becase support of this field is not fully laboured. [ Update 2010.03.10: After some experimentations I found that Apache POI can read and process new Excel ( xlsx ) documents including calculating very complex formulas: Basically, cell.getStringCellValue() gives the evaluated outcome. This way, I didn't have to hack POI. That's great!] I choosed to start two methods: Knowing exact static structure of the Excel template document, I do problematic calculations in the reader program itself, eliminating POI's formula support. I study Apache POI's internal structure and try to make up the missing functionality. Unfortunately, POI isn't amendable in a non-invasive way with registering components at certain extensi...