2

I am working on adding CSS file in an Fxml file like below.

<BorderPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="1200.0" stylesheets="@../../../resources/css/home.css" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ctc.controller.SupplierUpdateController">

As you can see I have added the css like stylesheets="@../../../resources/css/home.css"

This has done by using scene builder in windows and it worked fine. But when I have created the jar and run on ubuntu 16.04, the CSS does not get applied and there is following error in the console.

Oct 15, 2017 6:18:02 PM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged
INFO: Could not load stylesheet: rsrc:../../../resources/css/home.css

This was working properly when I am running the application while in eclipse in ubuntu. But for the ar created it is not taking the CSS files.

4
  • I am sure that the jar is not going to work on windows too. You need to specify the full path and replace all the '../..' with the correct folders name Commented Oct 15, 2017 at 20:20
  • This is working in windows without any issue. And when I create the jar with Intellij IDEA it worked perfectly in ubuntu too Commented Oct 16, 2017 at 5:49
  • Mr Lister, actually this is not a web application. It is a JavaFx Desktop application. Commented Oct 16, 2017 at 8:37
  • @ChamaleeDeSilva Sorry about that. But my point still stands: if you have a subdirectory named Resources, Windows won't mind if you refer to it by "resources" in the application. Ubuntu does. Commented Oct 17, 2017 at 17:26

1 Answer 1

1

I once had similar issues when I didn't place the FXML-file itself within the resources-folder. The resources-entry within your path suggests that your FXML-file also seems to be outside the resouces-folder. Try the following structure:

resources/css/home.css
resources/your/package/yourlayout.fxml

Then referencing "@../../css/home.css" inside the yourlayout.fxml should be no problem anymore.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.