Category Archives: Eclipse

Eclipse Java

Eclipse/JUnit: CreateProcess error=206, The filename or extension is too long

If you encounter problems with running junit test in Eclipse and you get following exception:

Exception occurred executing command line.
Cannot run program "C:\Program Files\Java\jdk1.7.0\bin\javaw.exe" (in directory "C:\......"):
CreateProcess error=206, The filename or extension is too long

please download patch for Eclipse.

For Eclipse Juno and newer:
https://bugs.eclipse.org/bugs/attachment.cgi?id=216593
For older Eclipse:
https://bugs.eclipse.org/bugs/attachment.cgi?id=219900

After download back up existing eclipse/plugins/org.eclipse.jdt.launching_3.*.jar
Copy and paste classes in the patch to org.eclipse.jdt.launching JAR (replace existing files).
Restart Eclipse.

For me it worked.

In bug report Bug 327193 it is considered fixed, but it happen to me recently with Eclipse Kepler 4.3.2.

Eclipse Java

Fluent Builder Generator Eclipse Plugin

I was looking recently for a nice way to generate Fluent Builder pattern code in Eclipse. I tried two plugins

  1. Builder Pattern Eclipse Plugin (https://github.com/henningjensen/bpep)
  2. fluent-builders-generator-eclipse-plugin (https://code.google.com/p/fluent-builders-generator-eclipse-plugin/)
but both are not enough for me. I was looking for a plugin with ability to generate Fluent Builder for immutable class with final fields. Unfortunately both mentioned plugins work only with mutable classes.
So I decided to write my own plugin as a fork of BPEP.
Below you can see some example class and builder generated for it by FBGEP – Fluent Builder Generator Eclipse Plugin.
public class Person {
    private final String firstname;
    private final String lastname;
    private final String address;
    private final String zipcode;
    private final String city;

    public Person(String firstname, String lastname, String address,
            String zipcode, String city) {
        this.firstname = firstname;
        this.lastname = lastname;
        this.address = address;
        this.zipcode = zipcode;
        this.city = city;
    }
}

Class with generated fluent builder:

public class Person {
    private final String firstname;
    private final String lastname;
    private final String address;
    private final String zipcode;
    private final String city;

    public Person(String firstname, String lastname, String address,
            String zipcode, String city) {
        this.firstname = firstname;
        this.lastname = lastname;
        this.address = address;
        this.zipcode = zipcode;
        this.city = city;
    }

    public static class PersonBuilder {
        private String firstname;
        private String lastname;
        private String address;
        private String zipcode;
        private String city;

        public PersonBuilder withFirstname(String firstname) {
            this.firstname = firstname;
            return this;
        }

        public PersonBuilder withLastname(String lastname) {
            this.lastname = lastname;
            return this;
        }

        public PersonBuilder withAddress(String address) {
            this.address = address;
            return this;
        }

        public PersonBuilder withZipcode(String zipcode) {
            this.zipcode = zipcode;
            return this;
        }

        public PersonBuilder withCity(String city) {
            this.city = city;
            return this;
        }

        public Person build() {
            return new Person(firstname, lastname, address, zipcode, city);
        }

        public static PersonBuilder person() {
            return new PersonBuilder();
        }
    }
}

GitHub repository:

https://github.com/coffeedriven/fbgep

Eclipse plugin update site:

http://coffeedriven.org/fbgep/update