Something weird with the assets folder

So.
This is my first topic/thread/issue I post on this website.
Tell me if I should post this somewhere else.

I started programming in Java almost 6 months ago and a while ago I started to use jME3 (after I found LWJGL too hard).

I’m currently trying to make an MMORPG-like game, and I’ll add servers later on.

I made a class called Mob, which is extended by NPC and Player. The standard mob constructor requires the app (for the rootNode) and a file, an .ini file. This file is then used to get all standard values (as I want it to be easily configurable).
When creating a character (in a layout with nifty), the ClassBuilder is called, which has the function public Player buildWarrior() {
return new Warrior(this, new File(iniFilePath)
}

The .ini file itself is located under “Project Folder/assets/Config/Warrior.ini”.
For iniFilePath, I first used “Config/Warrior.ini”
That gave a NullPointerException, so I used “assets/Config/Warrior.ini” instead, which did work.

Why did the second solution work? Did I do something wrong? Do I have to post all 4 classes that have something to do with it?

Oops! I just realized my mistake.
(Why is the spelling corrector set on American English? Colour not color!)
For everyone who made this mistake:

Only if you use the assetManager you don’t have to type “assets/”.
If you have your own manager/locator or something, you have to specify the exact path; there isn’t an extra object doing that for you!

This setting is in your browser…

1 Like

Use the classpath instead of File objects, otherwise theres nasty surprises when you first deploy your app.

Could you elaborate or give a simple example?
I’m not really familiar with that classpath thing too (I’ve heard that word years before but never needed any detailed knowledge since most of the time I was doing C++ or simple .bat started Java programms)
Or maybe you have a good link which explains this for jME and deployment? :chimpanzee_smile:

It is the path where the JVM loads classes from: Classpath - Wikipedia

Java uses a classloader to load classes from the classpath. The classloader can also be used to load a file (as a stream - not as a File class) from the classpath.
https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getResourceAsStream(java.lang.String)

Hm … I still don’t understand. Maybe someone could explain what @normen meant by giving a simple example?

1 Like

Thanks, I will look into this (not now, since it’s pen-and-paper-fever again, but later).

The sad thing that I realized: Maybe I need to hire someone who delves into this elite Java stuff and build system configurations. Or I just switch back to C++, learn Unreal and do things that I understand already. Nevermind, I will not stop before I’ve released a minor game with jME for free. This way I can find out if despite all the problems I can make at least something with this open source engine.