nus-cs2103-AY1718S1 / forum

Discussion Forum
5 stars 0 forks source link

getResource() returns null in AddressBook level 3 #44

Closed syy94 closed 7 years ago

syy94 commented 7 years ago

image

This is a fresh clone of the addressbook level 3 repo. However the application cannot start as the

Main.class.getResource("ui/mainwindow.fxml")

keeps returning null.

When I create a new javafx project, 'getResource()' works and the sample application runs.

I tried:

damithc commented 7 years ago

@syy94 did you follow all the steps in the setup instructions. e.g. the step for setting up the working folder

syy94 commented 7 years ago

Thanks for the advice, everything is working fine now.

I initially checked out using Intellij which helps configure the project such that I do not have to edit any run configurations while allowing all the test cases to pass. However, this caused some problems with the main program.

After I followed the setup instructions, it works. Then out of curiosity I tried to isolate the problem and I found out that Gradle was the one causing this problem.

The problem arises when:

  1. checking out via Intellij which detects the project as a Gradle project
  2. importing the project and chose the Import project from external model Gradle option
  3. linking the project to Gradle. image

So the solution to my problem is follow the setup instructions and do not link the project to Gradle.

syy94 commented 7 years ago

Accidentally clicked the close issue button.

syy94 commented 7 years ago

Fixed Gradle.build and moved the .fxml files and .css file such that linking to Gradle will not have getResource() returning null. Commit can be found here

damithc commented 7 years ago

Closing as this is no longer relevant to other students. Thanks for additional info and troubleshooting attempts @syy94