java.lang.IllegalArgumentException: Invalid URL or resource not found
Solution 1:
Image image = new Image("za.png");
The constructor of this needs to point to a URI, so if you're pointing to something on the file system it'd be:
Image image = new Image("file:za.png");
Alternatively, you could do:
Image image = new Image(new File("za.png").toURI().toString());
...which is arguably neater. If the image is bundled in your jar rather than on the filesystem, you can obtain the URI like so:
Image image = new Image(getClass().getResource("za.jpg").toURI().toString());
Most methods / constructors in JavaFX that take a string as a parameter in this way (i.e. specifying a resource) do so via string URI's rather than just a plain file path or URL.
Solution 2:
Do
javafx.scene.image.Image image = new javafx.scene.image.Image(getClass().getResource("za.jpg").toExternalForm());
ImageView iv = new ImageView(image);
Or simply
ImageView iv = new ImageView(getClass().getResource("za.jpg").toExternalForm());