This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a question about final jar. I package in the folder code a sudirectory called images that contains the images that I used for the GUI. In the instructions.html said:
A directory called code, containing all the source code and related parts of your project. You must create subdirectories within this to reflect your package structure and distribute your source files within those directories.
I think the images and the userguide.html are part of my project, but I don't want to fail by included in the folder code. Could you confirm me if its correct my jar file?
Hi Karla, I assume you use some icons for your GUI buttons and such so you need to include your "images" folder into your runme.jar file.
To my understanding you should put your images folder your code directory and when compiling also copy the images folder to the "classes" directory. Just use the -d flag images as if it were a package.
This way you wouldn't need to worry about improper file structure for your runme.jar file. Hope this helps.
I simply move the images folder and userguide.html to the root. This way when you create your runme.jar file you can do assuming you first compile to destination classes folder:
jar cvfm runme.jar manifest.txt -C classes . images userguide.html
Hence if you look inside your runme.jar file it would look:
If you can put the images folder and userguide.html inside your classes folder say when you compile then your jar file structure is your classes folder structure. I'm sure those IDEs will setup this nicely but then you will need to put your images and userguide.html inside your code folder and not the root.
If your images are used in your application (icons, for example) then they should be in the code folder (and in runme.jar). If the userguide opens from your application (when pressing F1 for example), then it should also be in your code folder and runme.jar.
Otherwise, there's no need to include them in the code folder or runme.jar, you should only have them in your documentation folder.
K the file structure you present is not the same as the one requested by Sun, they request the following file structure:
A jar or zip file called scjda-aaaaaaaaa.jar/zip where aaaaaaaaa is a unique number identifying the student (see SCJD FAQ).
This file must have the following layout and content in its root:
-db-1x2.db (or whatever your unchanged original db file is called)
-code folder (containing all source code and related partsd of the project - sub packaged as appropriate)
-docs folder (which includes the following in its root
-javadoc (containing all the HTML/Javadoc stuff)
-userguide.txt or multiple HTML files accessble from a starting document called userguide.html
Although your runme.jar should contain your images etc these should be within your code directory. Personally I wouldn't deviate from the requested file structure asked for on the assignment as shown above. Sun has software that does automatic file structure testing etc on the asked for format
and deviation from this could result in an automatic failure.
If you don't use images in your application, why should you include them in your code folder? I had images for my userguide, but I did not have the userguide or these images in the runme.jar or the code folder...
Joined: Mar 08, 2009
Again, Thanks for answere me.
Yes, I have images in the GUI and the menu display userguide.html.
Joined: Feb 29, 2008
In this case, I think it's ok like this.
Anyway, I for one would keep my resources close to the code, so I'd have something like:
suncertify/client/resources/icons - for images used as icons (or "images" if you have something else besides icons)
suncertify/client/resources/userguide - and in here the userguide.html and it's own images (if it has any)