title: Imageview in Javafx : Invalid URL
body: <p>In am trying to run the following code and it throws an <code>IllegalArgumentException</code> </p>
  
  <pre><code>public class Receta {
  private final StringProperty nombre;
  private final StringProperty dificultad;
  private final StringProperty tipo;
  private final StringProperty plato;
  private final StringProperty ingredientes;
  private final StringProperty observaciones;
  private final StringProperty[] pasos = new StringProperty[10];
  private final StringProperty comensales;
  private final StringProperty tPrep;
  private final StringProperty tCoc;
  private final IntegerProperty valoracion;
  private HBox caja = new HBox(3);
  private ImageView imagen;
  private VBox cajaV = new VBox(2);
  private HBox cajaDif = new HBox(2);;
  
  public Receta(String n){
      nombre = new SimpleStringProperty(n);
      dificultad = new SimpleStringProperty("Normal");
      tipo = new SimpleStringProperty("Primero");
      plato = new SimpleStringProperty("Carne");
      ingredientes = new SimpleStringProperty("Ninguno");
      observaciones = new SimpleStringProperty("Nada");
      comensales = new SimpleStringProperty("2");
      tPrep = new SimpleStringProperty("180");
      tCoc = new SimpleStringProperty("20");
      valoracion = new SimpleIntegerProperty(4);
      imagen = new ImageView("/Recetas/src/lupita.png"); //The exception is thrown here
      cajaDif.getChildren().addAll(null,new Label("Normal"));
      cajaV.getChildren().addAll(cajaDif,new Label(tPrep.get()));
      caja.getChildren().addAll(imagen,new Label(n),cajaV);
  }
  
  private ImageView imagenDif(){
      String d = dificultad.get();
      if(d.equals("Facil")) return new ImageView(new Image("../../facil.png"));
      if(d.equals("Medio")) return new ImageView(new Image("../../medio.png"));
      return new ImageView(new Image("../../dificil.png"));
  }
  
  public String getNombre(){
      return nombre.get();
  }
  public void setNombre(String n){
      nombre.set(n);
  }
  
  public String getDif(){
      return dificultad.get();
  }
  public void setDif(String d){
      dificultad.set(d);
  }
  
  public String getTipo(){
      return tipo.get();
  }
  public void setTipo(String t){
      tipo.set(t);
  }
  
  public String getPlato(){
      return plato.get();
  }
  public void setPlato(String p){
      plato.set(p);
  }
  
  public String getIngr(){
      return ingredientes.get();
  }
  public void setIng(String i){
      ingredientes.set(i);
  }
  
  public String getObs(){
      return observaciones.get();
  }
  public void setObs(String o){
      observaciones.set(o);
  }
  
  public String getPaso(int i){
      return pasos[i].get();
  }
  public void setPaso(int i, String p){
      pasos[i].set(p);
  }
  
  public String getCom(){
      return comensales.get();
  }
  public void setCom(String c){
      comensales.set(c);
  }
  
  public String getTPrep(){
      return tPrep.get();
  }
  public void setTPrep(String t){
      tPrep.set(t);
  }
  
  public String getTCoc(){
      return tCoc.get();
  }
  public void setTCoc(String p){
      tCoc.set(p);
  }
  
  public int getVal(){
      return valoracion.get();
  }
  public void setVal(int v){
      valoracion.set(v);
  }
  
  public HBox getCaja(){
      return caja;
  }
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code>Exception in Application constructor
  java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
  at com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
  Caused by: java.lang.RuntimeException: Unable to construct Application instance: class recetas.MainRecetas
  at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
  at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(Unknown Source)
  at com.sun.javafx.application.LauncherImpl$$Lambda$50/1323468230.run(Unknown Source)
  at java.lang.Thread.run(Unknown Source)
  Caused by: java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  at java.lang.reflect.Constructor.newInstance(Unknown Source)
  at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$158(Unknown Source)
  at com.sun.javafx.application.LauncherImpl$$Lambda$51/934330049.run(Unknown Source)
  at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(Unknown Source)
  at com.sun.javafx.application.PlatformImpl$$Lambda$45/186276003.run(Unknown Source)
  at com.sun.javafx.application.PlatformImpl.lambda$null$170(Unknown Source)
  at com.sun.javafx.application.PlatformImpl$$Lambda$48/97828179.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(Unknown Source)
  at com.sun.javafx.application.PlatformImpl$$Lambda$47/237061348.run(Unknown Source)
  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
  at com.sun.glass.ui.win.WinApplication$$Lambda$36/2117255219.run(Unknown Source)
  ... 1 more
  Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
  at javafx.scene.image.Image.validateUrl(Unknown Source)
  at javafx.scene.image.Image.&lt;init&gt;(Unknown Source)
  at javafx.scene.image.ImageView.&lt;init&gt;(Unknown Source)
  at recetas.model.Receta.&lt;init&gt;(Receta.java:41)
  at recetas.MainRecetas.&lt;init&gt;(MainRecetas.java:20)
  ... 18 more
  Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found
  ... 23 more
  Exception running application recetas.MainRecetas
  </code></pre>
  
  <p>The main simply calls <code>Receta's constructor</code> and there, the exception is thrown, i have checked and changed several times the <code>url</code> of the image just in case it was wrong but it doesn't seem so.</p>