Apprenders and formating a default java.util.logger

java.util.logging.FileHandler.level = INFO
java.util.logging.FileHandler.pattern = log.%u.%g.txt
java.util.logging.SimpleFormatter.format= %1$tl:%1$tM:%1$tS %1$Tp %2$s %4$s: %5$s%n

More info about SimpleFormatter:

More Info about formatting params:

Pass parameters to java main method using graddle

To pass for example a param “-a” with value “” to the static void main method that tha graddle task will run,  you will need to :

  • add following entry to file, or assert that it is already there:
    run {
        if (project.hasProperty("appArgs")) {
            args =
  • run graddle on the following form:
    gradle  run  -PappArgs="['-a',  '']"

Create a correct 201 Created response with JAX-RS

public Response createProject(@Context UriInfo uriInfo, JsonObject json) {
        Project project = projectConverter.fromJson(json);
        project = em.merge(project);

        URI uri = uriInfo.getBaseUriBuilder()
                .resolveTemplate(PathExpressions.workspaceId, getCurrentWorkspace().getId())
                .resolveTemplate(PathExpressions.projectId, project.getId())

        return Response.created(uri).build();
The @Context UriInfo uriInfo provides information about the current URI. 
The .path(ProjectResource.class)  call will return the path used for the ProjectResource.class. 
The .resolveTemplate("{workspaceId:\\d+}", getCurrentWorkspace().getId())  will replace the workspaceId template variable for the actual wokspace id.

Once the whole path has been created, it is only needed to put it into a created response.

Collect into Jsonp JsonArray using without using foreach

Each collector has three parts:

  • A supplier: provides with instances of the accumulator.
  • An accumulator: accumulates the objects being collected. Several instances of accumulator can be used.
  • A combiner: combines all the accumulator putting all collected objects together.

For the JsonArray the combiner, accumulator  and combiener are respectively:

JsonArrayBuilder createArrayBuilder()
JsonArrayBuilder add(JsonValue value)
JsonArrayBuilder add(JsonArrayBuilder builder)

    public JsonArray getArray(Jsonable[] objects) {
        return Stream.of(objects).map(Jsonable::toJson)


    public static class Jsonable {

        public JsonObject toJson() {
            return Json.createObjectBuilder().add("someId",;

Get java.util.logging working on UnitTesting

If you need to active the java.util.logging on your test, you can achieve it just adding the vm option

where can be something like

handlers = java.util.logging.ConsoleHandler
your.package.level = FINE
java.util.logging.ConsoleHandler.level = FINE

You can find a more complete example on


Run Vert.x app from intellij

To run Vert.x on intelliJ, it is only required to create a standard application Launcher with the following parameters:

  • Main class: the vert.x main class, i.e. io.vertx.core.Starter or whatever it is for your version.
  • VM options: whatever you need or empty
  • Program arguments: run de.lacambra.vertx.MyFirstVerticle
  • Working directory: normally your project directory