Press "Enter" to skip to content

Tag: Java

Create a zip/tar/tar.gz/tar.bz2 archive with Maven

Until now all I had to generate form Maven was either a JAR file, or a WAR for web apps or EAR for enterprise applications. But this week I got a new task: I had to export the frontend (HTML, CSS, JS and all other assets, like images, etc) of the web application I am working on in a zip archive. I could have done this from /bin/bash, as I am already running some command line statements to run webpack and compile my React JS project, but I already output two EAR files based on the same frontend during Maven build, so I thought it would be more elegant to generate the 3rd output from Maven as well, despite it being a simple zip archive.

Comments closed

WebSocket example in Java

WebSocket is a communication protocol providing a bi-directional communication channel between client and server. It allows us to directly send a message to the clients whenever something changes on the server side and we want all clients to be notified. Let’s see the skeleton for a simple WebSocket example in Java.

Comments closed

Solving the Jetty file locking problem when starting it programmatically

In the past few weeks I was required to create a prototype for the frontend of a project and because the focus is only on the frontend, I’ve chosen Jetty to create a simple mock server that would respond with simple JSON messages or stream some image files. I also use Jetty to serve the static files, like static images, CSS, JS that I am continuously modifying while developing the new frontend. Because I am developing on Windows, I have run quite soon into the file locking problem.

Comments closed

Speeding up Eclipse

Do you usually ask questions during an interview about the computer and other hardware you will be using if you get the job? And about the software? Well, I didn’t, and after using IntelliJ Idea from the beginnings and never having less than 8 gigs of RAM in my machines, I woke up with a laptop with 4GB RAM and Eclipse.

Comments closed

Using Cucumber in Java unit testing

While working in Ruby at my previous workplace we were required to write unit tests using RSpec and end-to-end tests using Cucumber and Watir webdriver. I wasn’t a big fan nor am I today of writing tests, but for some reason I just loved Cucumber. We wrote them together with the members of the QA and it was fun, because we both were thinking about all the possible cases to test and not about the way the tests were going to be implemented. Furthermore, it was clear for everybody what I wanted to test, as the scenarios were written in natural language.

Comments closed

Simple JAX-RS Web Service on JBoss (RESTEasy)

Implementing RESTful services in PHP or Ruby was very easy, I love its simplicity compared to SOAP. But implementing a RESTful service for the first time in Java has caused me a bit of a headache. In the beginning I was quite confused when it came to JAX-RS specification and the different implementations (Jersey, RESTEasy, …), but then it’s so easy, I don’t know why I have wasted so much time figuring out what I needed…

Comments closed

Add custom HTTP header to an Axis 2 SOAP request

A few days ago I had a challenging task in Java: I had to add a custom header to my SOAP request using Axis 2. But the custom header had to be passed as a HTTP header, not in the SOAP Envelope, since it was used by a Filter and it had nothing to do with the rest of the request. The Filter simply gets a ServletRequest, gets the extra parameter from the HTTP header and does something with it, without having to parse the SOAP Envelope. It’s not that hard to do, there is documentation on this issue, but because there can hardly be found a good example, one may waste several hours trying different solutions.

Comments closed