Zeyad
Zeyad

Reputation: 626

How to specify the path relative to some folder in Java?

I am trying to specify the path of an image, and the path of a stylesheet using the following two codes:

pane.getStylesheets().add("src\\dbgui\\Style\\CSS\\base.css");
btn_remove.setStyle("-fx-background-image: url(Style/Images/add.png)")

neither works, i just don't understand how paths works in java, should i specify the path relative to the root folder, or relative to the src folder or relative to what exactly ? because i don't want to use the full path starting by the C: drive, well actually even when i tried this, it didn't work either.

Is there a way to set a relative folder to specify paths from in java ? I am using Netbeans IDE.

Upvotes: 0

Views: 67

Answers (1)

Rumado
Rumado

Reputation: 327

path is specified in the below format -: (Assuming current file is located in a particular folder)

../ : This goes one step above the current folder

./childFolderName : This goes into a child folder in the current folder (. refers to current folder)

../folderName : This goes to a folder inside the parent folder

Upvotes: 1

Related Questions