GeoTools : ExternalGraphicsJava

We can define in java the use of external graphics too. Here is a code to do this (thanks to Hervé) :

            StyleBuilder sb = new StyleBuilder();
            PolygonSymbolizer sym;
            Style highLightStyle;
            ExternalGraphic icon;
            Graphic graph;
            PointSymbolizer iconSym;
            icon = sb.createExternalGraphic(
            graph = sb.createGraphic(icon,null, null,1,32,0); //32 it the pixel size you want (if it is different from the icon size, the icon will be stretch or shrink)
            iconSym = sb.createPointSymbolizer(graph);
            highLightStyle = sb.createStyle(iconSym);

you can also use an absolute path :
            icon = sb.createExternalGraphic("FILE:///C:/my/path/to my file/icon.gif","image/gif");