Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Resources are loaded when compiling manually with javac

Tags:

java

javac

I want to manually compile Java-Code with javac. I'm using multiple Images loaded with getClass().getClassLoader().getResource("...") If I run my Code in an IDE everything works fine. But when I'm trying to compile with javac no Resources are loaded. Is there a way to specify the Folder which contains all my Resources? I already tried --add-module but this didn't work either. My command for compiling looks like the following: javac -d ./out main/ai/*.java main/logic/*.java main/gui/*.java main/network/*.java && java -classpath ./out logic.Launcher


1 Answers

The solution was to just include the path to my Resource Folder in the classpath. I just had to add -classpath path/to/my/res So my working command looks like this: javac -d ./out main/ai/*.java main/logic/*.java main/gui/*.java main/network/*.java && java -classpath ./out:./res logic.Launcher


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!