javafx - Java - Import main class in subfolder for Image -


in project need create image each object when created.

    public abstract class pirate extends imageview {     protected static int piratespeed, piratescore;     protected string word;      public pirate(string face, string word) {         this.setimage(new image(piratesandtreasures.class.getresource("/resources/" + face).toexternalform()));         this.word = word;     } } 

piratesandtreasures main class , project structure looks this:

enter image description here

as far understood need access main class when using this:

new image(themainclass.class.getresource("/resources/" + picture).toexternalform())); 

..well here issue: couldn't find way import upper folder or "src".

any appreciated.

update: states "cannot resolve symbol piratesandtreasures"

you try using imageio.read(getclass().getresource("/resources/" + picture)) way not dependent on wherever main class is. should work same have above since these sub folders under src.


Comments