Adding images for ClassResourceObject

There’s no such thing as a stupid question :slight_smile:

To access images through ClassResources, you should put your image in the CLASSPATH. So in eclipse it should be enough to put your image in the same package as your Application class:

and use it like this:

package com.example.helloworld;

import com.vaadin.Application;
import com.vaadin.terminal.ClassResource;
import com.vaadin.terminal.Resource;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.Window;

public class HelloworldApplication extends Application {
	private static final long serialVersionUID = -6505074926320503537L;

	@Override
	public void init() {
		Window mainWindow = new Window("Hello");
		Resource myImageResource = new ClassResource("image.png", this);
		mainWindow.addComponent(new Embedded("My pretty image", myImageResource));
		setMainWindow(mainWindow);
	}
}

Also look into ThemeResource for images that you might want to change depending on which theme you set for your application.

HTH,
/Jonatan