Reputation: 902
When I clean and build a project in NetBeans, the .jar file appears in the dist folder, like it's supposed to. But what if I have multiple files under the project? What happens to those files? E.g. I have a Game project, and under it are the different characters(knight, rogue, etc.) but I only see a game.jar file when I clean and build, I want to know what happens to the individual files. Thanks
Upvotes: 0
Views: 2242
Reputation: 3110
All resources get compiled into the JAR file. If you want a separate JAR for the resources, you'll need to split the project into two maven projects: one jar for the code, one for the resources. You can then create a third project that would generate a distribution.
That's a lot of work, though. It's.a lot easier tO keep everything in one JAR unless you have explicit dynamic loading requirements.
Upvotes: 0
Reputation: 20061
Those files should be in the jar file as compiled .class files. It's easy to double check what's in the jar file since it's in zip format. You can use a program like 7-Zip to open it, or rename it to the zip extension (e.g. from mygame.jar to mygame.zip) and whatever OS you're using probably has some way to open it.
When you open or extract the jar file you'll find the compiled class files in a directory structure that reflects your package structure. For example, if you have Knight.java in the directory src/game/characters/Knight.java
in the jar file you'll find something like classes/game/characters/Knight.class
.
The name "jar" is an abbreviation of "Java archive". It stores all the classes and other resources (for example, images) in a project.
Upvotes: 3
Reputation: 55223
The classes you have defined in .java
files will be compiled into .class
files - these are contained in the .jar
file.
Upvotes: 1