Where does javafx.scene.image.Image(“flower.png”) look for flower.png?

后端 未结 3 1487
长发绾君心
长发绾君心 2020-11-27 07:36

I would like to know what the JavaFX Image constructor\'s relative path resolution algorithm is for:

  1. Stand-alone apps.
  2. Browser deployed apps.
3条回答
  •  有刺的猬
    2020-11-27 07:56

    The answer is "/" if case you are using getClass().getResourceAsStream(), i.e. the root of your jar file (inside it). Not user.dir nor where the package is hosted

提交回复
热议问题