aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Question about package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Question about package" Watch "Question about package" New topic
Author

Question about package

K. Duran
Greenhorn

Joined: Mar 08, 2009
Posts: 3
Hi!

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?

[Andrew: Edited for readability]
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1977
    
    7

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.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7
K. Duran
Greenhorn

Joined: Mar 08, 2009
Posts: 3
Thanks for the quick answer.

I don't have problem with my runme.jar, my doubt is about folder code... Must I include the images and file.html in this folder? or only my source code?

Thanks again.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1977
    
    7

Your file structure should look like this:


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:
-images
-userguide.html
-suncertify

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.

Alecsandru Cocarla
Ranch Hand

Joined: Feb 29, 2008
Posts: 158
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.


SCJP 1.4 100%
SCJD 99.5%
Kevin Florish
Ranch Hand

Joined: Jan 06, 2009
Posts: 164
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:

-runme.jar
-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)
-version.txt
-docs folder (which includes the following in its root
-instructions.html
-javadoc (containing all the HTML/Javadoc stuff)
-choices.txt
-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.

Cheers Kevin.

Java5 Tutorials | Java6 Tutorials | HTML/CSS Tutorials | JavaScript and jQuery Tutorials
Alecsandru Cocarla
Ranch Hand

Joined: Feb 29, 2008
Posts: 158
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...
K. Duran
Greenhorn

Joined: Mar 08, 2009
Posts: 3
Again, Thanks for answere me.

Yes, I have images in the GUI and the menu display userguide.html.

-
Is correct?...

Thanks.
Alecsandru Cocarla
Ranch Hand

Joined: Feb 29, 2008
Posts: 158
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)
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1977
    
    7

Hi I was doing something similar to my in-app user guide/help. And I figured a way how to load html/images if your html is inside the runme.jar file

Suppose you have your userguide.html in the your suncertify package (oh don't put it in the default package cos I don't think it will find the path). Inside your runme.jar file may look like this:


Then in your program use the ClassLoader


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about package
 
Similar Threads
Where to put the images that are used in the userguide.htm
NX:URLyBird.1.3.1,about Packaging of Submissions,thx!!!
NX: final packaging and the big JAR
question about userguide.html
elp Needed for SCJD Assignment Deliverable