not just this, other codes have the same problem. just can\'t use ImageView.
Environment : macOS, IntelliJ
Caused by: java.lang.IllegalArgumentException: Invalid
The Image constructor takes a url as a parameter. If you don't put a protocol in it, then it assumes that the item comes off of the classpath. Obviously, /Users/fangyuan/Desktop/PIC.png
won't be in your classpath.
To read from a file instead of the classpath, then stick the file://
protocol in front of the path you want to read:
file:///Users/fangyuan/Desktop/PIC.png
Or
Paths.get("/Users/fangyuan/Desktop/PIC.png").toUri().toString()
which would output the same thing.