When to use Optional in Java?

“you should rarely use an optional in any other capacity than as a return value”. “you should declare a method to return Optional<T> if it might not be able to return a result AND clients will have to perform special processing if no result is returned”. From Effective Java by Joshua Bloch (Third Edition), pages…… Continue reading When to use Optional in Java?

Categorized as Java

Testing myth: “The code is so simple – it doesn’t need a test”

If the code is so simple, then it will be simple to test it. And at some point, it’s likely the feature will be enhanced. If there is an existing test then it should be simple to enhance it. If there isn’t an existing test then things can quickly get messy. The more complex the…… Continue reading Testing myth: “The code is so simple – it doesn’t need a test”

Avoid the pain of uberjar/shade

So you want an executable jar. It’s got lots of dependent jars. What’s a geek to do? There is the uberjar plugin for maven. But it doesn’t seem to be supported any more, it’s not in maven central, and some people report classloader issues (it works some classloader magic). There is the Shade plugin for…… Continue reading Avoid the pain of uberjar/shade

Categorized as Maven

Maven “Missing indirectly referenced artifact”

I recently got an Maven error something like “Missing indirectly referenced artifact javax.transaction:jta:jar:1.0.1B:compile”. I fixed it by adding an extra repository in my pom.xml … </build> <repositories> <repository> <!– For jta jar –> <id>maven2-repository.dev.java.net</id> <name>Java.net Repository for Maven</name> <url>http://download.java.net/maven/2/</url&gt; <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <dependencies> …

Categorized as Maven Tagged

Javapolis 2007 Technology Highlights

Tech highlights from Javapolis 2007: Java Content Repository now supported by many vendors slick demo of a Jackrabbit-based commercial product from day.com JCR 2.0 is in the pipeline Glassfish open source application server is now the reference implementation of the Servlet API v3 (currently in beta) is more modular. The demo had a fast startup…… Continue reading Javapolis 2007 Technology Highlights

Categorized as Java Tagged