# Building jar with resources without IDE

This topic is 618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have created a manifest file for my desktop Java game that is used to create a jar file automatically from my shell script and now I need to add resources into the jar file.  :)

Is there a simple way to specify a folder in the manifest file without depending on additional tools? All guides point to the obvious way to just point and click in Netbeans but I want to know how the build process works so that I can fix things when they break using only the JDK tools.

Shell script for building the jar:

chmod +x ./compile.sh
./compile.sh
cp ./manifest.txt ./../output
(cd ./../output;
jar cfm Game.jar manifest.txt *
chmod +x ./Game.jar
java -jar Game.jar ./../source/media/
) 

I am currently giving the path of the media folder as a command line argument since it might be useful later for mods.

The manifest only contains the main class name for now and I haven't figured out a good namespace for Main yet.

Main-Class: Main

##### Share on other sites

It is a zip file format, it requires a few specific items.  Clicky

At a glance from your description it looks like your manifest file has the wrong name -- MANIFEST.MF instead of manifest.txt -- and it is not in the META-INF directory.

I'm pretty sure they're also case sensitive, all uppercase.  I think (but I'm not absolutely certain) that the jar tool does it automatically, but that's the first place I'd check.

##### Share on other sites
chmod +x ./compile.sh
./compile.sh
cp ./MANIFEST.MF ./../output
(cd ./../output;
jar cfm Game.jar MANIFEST.MF * ./../source/resources/*.png
chmod +x ./Game.jar
java -jar Game.jar ./../source/media/
)


Thanks! Seems to work now after just adding the resource files in the jar command. :)

BufferedImage image = null;
try {
image = ImageIO.read(new File(this.externalMediaPath + fileName));
} catch(IOException e) {
try {
} catch(IOException f) {
f.printStackTrace();
return -1;
}
}


When the selected mod folder does not contain the image, it will now fall back on the built in resources.
I should probably check if the files exist before trying to load from one location at a time but I can fix that later.

1. 1
2. 2
3. 3
Rutin
18
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633659
• Total Posts
3013217
×