aspose file tools*
The moose likes Java Micro Edition and the fly likes how to get file names in jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "how to get file names in jar" Watch "how to get file names in jar" New topic
Author

how to get file names in jar

Pavel Kubal
Ranch Hand

Joined: Mar 13, 2004
Posts: 356
I have few png images in jar and I want to get their names. On J2SE I used File class, but on midp1.0 isn't File class. Any suggestion?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Um, wouldn't you already know what you put in your jar file?
You can't put in dynamic files into your jar file, and you won't be able to access someone else's jar file, so it is your and you should know what you pu tinto it.
Just my opinion.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Pavel Kubal
Ranch Hand

Joined: Mar 13, 2004
Posts: 356
I made midlet which shows few images as a slideshow. My chef has source codes and wants to create another application just by changing images. I'd like to develop midlet which loads file names and than shows images, so that my chef can only copy images and build (without changing source code).
Do I make myslef clear?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
I see two options:
1) Make defining the file names a part of the build process -- when your chef(?) builds the application, he needs to edit some text file listing all the images the midlet should display.
2) Rip the images out of the JAR file and place them on a web server for download. For example, the midlet could be pointed to a "gallery" URL where it would download a "gallery descriptor" document (lists the URLs and names for the images that are part of that particular gallery) and then proceed to download each individual image file. The midlet could store these images and the descriptor into RMS for persistent storage.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Yes, Lasse, I like your Images on a web server idea the best. Other than that, you will not be able to dynamically create a Jar file with file names you don't know, and expect to be able to find out what those filenames are.
Mark
Pavel Kubal
Ranch Hand

Joined: Mar 13, 2004
Posts: 356
Lasse, thank for your reply, but I said that I want my chef not to edit src code. Application should find filenames itself. And downloading from internet is for this type application the worst solution, 'cause it's offline midlet and downloading brings more problems ect.
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Like Mark and Lasse had stated, there is no way to dynamically discover filenames in a MIDP JAR file. I would suggest to write a more flexible build solution: You can write an ANT task which would re-generate part of your source code based on your current image names. That is not that difficult and would save you (or your client) from editing the source code.


Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
Pavel Kubal
Ranch Hand

Joined: Mar 13, 2004
Posts: 356
Yes, I just wanted to know if it is possible or not. Never mind. I wanted to help my chef with building new slideshow apps as easy as possible. It seems, that the easiest way how to do it is modifying source code. After all, it is just few (5-10) lines.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Another idea... You could enforce a naming convention for the images (e.g. slide-1, slide-2, slide-3, ...) and have your MIDlet try to "guess" the names by reading files in order until slide-n is missing.
Pavel Kubal
Ranch Hand

Joined: Mar 13, 2004
Posts: 356
Good idea. I'll do it...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get file names in jar