1

I'm not new to Java, but I'm also not amazing with the terms. I have been doing some studying on that stuff and getting the formal names for all the different things that happen during programming and compiling, etc.

Anyways, the problem I'm having is being able to pack a program into one neat .jar file, instead of having external folders such as "images" and "audio". Instead of the .jar file accessing the pictures from external folders (which are easily editable by anyone), I want the pictures to be compiled in the .jar file itself.

I have done research on already existing questions, but the results were either:

  1. It says how to do it in Eclipse (I can follow along, but I use Netbeans and things get sticky sometimes)
  2. It says some other different answer, like how to use external .jar files in your program.
  3. I just don't get it (due to my weak technical vocabulary).

Could someone please help me? Thanks so much!

Ashok
  • 134
  • 13
  • 1
    A jar file is basically a ZIP file. You can put the the files you want into the directory-structure that you desire and then "JAR" it (basically creating a single ZIP-like archive file. http://netbeans.org/kb/docs/java/quickstart.html#build – Darius X. Mar 15 '13 at 01:21
  • @JarrodRoberson no, a jar is a .zip that can physically hold its dependencies, access not need be external. – djechlin Mar 15 '13 at 02:03
  • Hm. I have succesfully made a resources folder in my src, and used getResource() to get the files. It works when run from netbeans, but it quits when I run it by double clicking on the jar file! The answer you guys linked me to has PART of the solution for this, but I tried everything and it still won't work... – Ashok Mar 15 '13 at 02:50

2 Answers2

1

I would recommend you look into using maven to create your project structure, manage your build life cycle, and create your jar artifacts. With maven you can instruct your build procedures to include dependecies and resources to be included, all inside your pom file.

Take a look at this In maven how can I include non-java src files in the same place in the output jar? for an example of how to configure your maven pom so that it builds a jar that includes resource files.

Community
  • 1
  • 1
Dave
  • 1,480
  • 3
  • 16
  • 26
0

You want to build a Maven assembly. See e.g. http://maven.apache.org/plugins/maven-assembly-plugin/

djechlin
  • 59,258
  • 35
  • 162
  • 290