Importing a CSS file from a JAR file...

Hi all,

I have a question related to CSS importing…
Following is the sequence of the things that I did…

  1. I created a vaadin project (let’s assume the project name as
    ) which contains the UI utility classes that I need. (classes such as CustomTextField, CustomDateField, CustomDropdown… etc)
  2. Then I added a theme to this project & applied some styles to those UI fields.
  3. After that, I exported that project as a JAR file (
  4. Then I imported that JAR (UTIL.jar) file as a library for one of my other projects (let’s assume the project name as
    ) .

Now I come to the question.
I need to import the

file in to my
ABCD project’s

file. How do I achieve this…??

The path to my styles.css file at UTIL.jar is as follows.
UTIL.jar → WebContent → META-INF → VAADIN → themes → util_theme → styles.css

Any help would be highly appreciated.

Thanks in advance.


Without doing a fair bit of coding, you can’t - it’s really quite complicated. In short - and without going into detail - you’d need to do something like

  • Create a servlet that will serve up the CSS from the resource sitting in your jar (using Classloader#getResource)
  • Create a mapping in the web.xml that will ensure
  • Change your abcd them styles.css to import the util css using the mapping you created above

If you could change your util.jar structure so that the css was in “VAADIN/themes/util_theme/styles.css”, then you could would be able to import the util theme from VAADIN/themes/abcd/styles.css as
@import …/util_theme/styles.css

i.e. you wouldn’t have to do too much heavy lifting (i.e. Vaadin already serves it’s own themes out of jars, and you could hook into that mechanism - but they need to be in the VAADIN/themes/name stucture).



Hello, I have a Vaadin 7 util project and exactly the same wish to use the styles defined in this jar in other projects. I enshured that my jar has exactly the same structure as the vaadin-themes jar (7.0.0.Beta3), (with the theme in VAADIN/themes/util/styles.css), but the projects using the util.jar don’t see my util theme. The util theme extends the chameleon theme and the project theme extends the util theme. What am I missing? The util.jar has also some Java classes and the Java classes are imported correctly in other projects.

Thank you,
Sabina Mirauta