[英]Java difference between (classpath relative path) and (document relative path)?
Description
描述
I am trying to understand what the above means.I have a project with the below schema: 我试图理解上述含义。我有一个具有以下架构的项目:
~~->And here is an image from the SceneBuilder :
~~->这是来自SceneBuilder的图像:
The problem
问题
First i want to access the image1.png
using ( document relative path ) which i think it is ../../resources/images/image1.png
and then i want to access image2.png
using ( classpath relative path ) which i have no idea what it means. 首先我要访问
image1.png
使用( 文档相对路径 ),我认为这是../../resources/images/image1.png
,然后我想访问image2.png
使用(classpath的相对路径 ),我不知道这意味着什么。
Finally
最后
I want to be soore that when i export the application as a .jar
file the images which are inside the .jar
files are shown as they are shown when i open the application in Eclipse. 我想被soore,当我的应用程序导出为
.jar
文件,该文件是内部的图像.jar
文件显示,当我在Eclipse中打开应用程序,他们所示。
This is actually about Java 9
.I have to change anything so the project is running smoothly with Java 9
?Will even .jar
files be accepted?I am curious for that. 这实际上是关于
Java 9
。我必须进行任何更改,以便该项目可以在Java 9
顺利运行?即使.jar
文件也可以接受?我对此感到很好奇。
Thanks for the effort. 感谢您的努力。
Classpath relative means the path will be relative to the classpath of the classloader used for loading the fxml file. Classpath relative表示路径将相对于用于加载fxml文件的类加载器的类路径。 You most likely do not want to use this option.
您很可能不想使用此选项。 Instead the document relative path: since
src
is not exported in to the jar, in Main.fxml
this should be 而是文档相对路径:由于
src
不会导出到jar中,因此应在Main.fxml
中
@../images/image1.png
or 要么
@../resources/images/image1.png
depending on eclipse storing the resources in a resources
directory in the jar file or not. 取决于Eclipse是否将资源存储在jar文件的
resources
目录中。 (Note SceneBuilder automatically adds the @
, if you select the appropriate option.) (请注意,如果选择适当的选项,SceneBuilder会自动添加
@
。)
As java 9 is concerned, I cannot tell you for sure, but the documentation contains a constant for the @
prefix so it's unlikely that document relative paths are removed in java 9. 就Java 9而言,我不能肯定地说出来,但是文档包含
@
前缀的常量,因此不太可能在Java 9中删除文档相对路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.