Tag: java

  • Switching between multiple Java versions on OS X quickly

    If you’re a Java developer like me, you will need to work on various Java versions. If so, adding the following in your ~./bash_profile makes switching between versions a snap. (As of this writing, I’m running on OS X El Capitan.) alias java6='export JAVA_HOME=$(/usr/libexec/java_home -v 1.6);java -version' alias java7='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7);java -version' alias java8='export…

  • How to install jshell via Homebrew

    At the time of this writing, Java 9 is in beta. I installed because I wanted to check out jshell, Java’s new REPL (read-evaluate-print-loop). On top of the below, I brew-installed jenv (a must for managing different JDK versions). $ brew install Caskroom/versions/java9-beta $ jenv add /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home $ jenv shell oracle64-9-ea $ java -version java…

  • Mongo DB: Iterate through a MongoCollection

    , ,

    This is specifically for Mongo 3.x, where MongoCollection is preferred over DBCollection. Adding for personal archiving. MongoCollection<Document> mongoCollection =             getMongoCollection(databaseName, collectionName);         FindIterable<Document> documents =             mongoCollection.find(eq(COLUMN, "lastName"))                 .sort(ascending("lastname"));         for (Document document : documents) {             …         }

  • Cucumber-JVM: Running a @Before step only for certain scenarios

    ,

    You can make use Cucumber’s @Before and @After to execute only for certain scenarios like the below. This is especially useful if you, say, wanted to make a (Mongo) DB connection for a few test scenarios. @Before("@mongo") public void beforeScenario() {   // actions } @After("@mongo") public void afterScenario() {   // actions } To complete the…

  • IntelliJ IDEA: Plugin to generate SerialVersionUID

    ,

    Easy as pie. 1. Go to: File > Settings > Plugins > Browse repositories > GenerateSerialVersionUID. 2. Install the plugin and restart. 3. Generate the ID by: Code > Generate > serialVersionUID or the shortcut.

  • Debugging the dreaded “SEVERE: Error listenerStart” and “SEVERE: Error filterStart” Tomcat error messages

    The solution is to add a logging.properties file inside WEB-INF/classes with the following: org.apache.catalina.core.ContainerBase.[Catalina].level = INFOorg.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler Source: Debugging the dreaded “SEVERE: Error listenerStart” and “SEVERE: Error filterStart” tomcat error messages « Trifork Blog / Trifork: Enterprise Java, Open Source, software solutions