I like to keep my application data and and code in different Source Packages in NB (don’t mistake with java packages).
So I did this time. Unfortunately it can’t get files via File object from one package to another. Here’s my package structure
Source Packages
|-[J]basicstuff
|-[J]net.abc.utils
assets
|-[F]Images
|-[F]Layouts
Legend:
- No indication – source packages added in NB’s project properties
- [J] Standard java package
- [F] – folder for data made with file manager
The thing is, I have my custom layout loader as I use my own GUI system. Layouts are JSON text files placed in assets/Layouts. Unfortunately my layoutmanager (which is another class in net.abc.utils) can’t load them. Whatever I do, I can’t load those.
I’ve tried
File layout = new File("assets/Layouts/layout.txt");
then
File layout = new File("../../../assets/Layouts/layout.txt");
Then I remembered it is four directories above, including src dir.
File layout = new File("../../../../assets/Layouts/layout.txt");
But it didn’t work either.
Even tried
File layout = new File("../../../../Layouts/layout.txt");
and
File layout = new File("../../../Layouts/layout.txt");
But those of course also didn’t work. Can you help me?
Dependent on the environment in which your application is (Standalone, ApplicationServer), you will need to use the appropriate
ClassLoader.Try something like this:
For use: