Creating jar files on the fly


#1

Hey, people. I know softwares like eclipse and netbeans can take the source code and subfolders from your project and create an executable jar file or J2ME app from all that. Can anyone tell me how Netbeans does this? I want to mimic this capability in a desktop program of mine. I’ve worked with the java.lang.Runtime class to run other execute commands on your computer from within your java code. Though this was cool, I was unsuccessful with my main goal.

I have written a J2ME program mobile ebook app for the ‘think and grow rich by napoleon hill’ pdf book. I can create a mobile ebook app for any pdf book, but I want to scale this so that none programmers can create a mobile ebook app for their favorite pdfs(for people who can’t afford blackberries that have file systems and that can run pdf readers).

I created a program that can extract the text from each page of a pdf and place the text in .txt files, a text file for each page of the pdf. I then copy this text files to the ‘res’ directory of my project. I change the number of pages of the app I want to create. change the name of the app, change the image for the project and build. Its that simple. But I want anyone without an IDE to be able to do this.


#2

Hello,
Have you tried using the java.util.jar utility?
It allows you read and create jar files on the fly.
It contains only a few classes. It gives one the notion that a jar file is a file system of it’s own.

Try it and have fun using it.
Cheers.


#3

Thanks. I’ll check it out, but I hope you know that you can’t create a jar file out of thing air . . . there have to be class files already and then folders with stuff like images etc. What I have in mind is a JavaSE program that can create a source code .java file(using file I/O) from a string representation of the source code in my JavaSE program. Then this .java file is compiled and preverified with the specific classes of the J2ME api, specifically cldc and midp. Then the .jar and .jad files can be created with the specific details for J2ME jar files.
Do you really think the java.util.jar utility you talked about can do all that? I’m asking cos I’ve observed that I never make myself clear enough either in audible speech or in writing. People always seem to extract some alternate meaning from the stuff I say, then I have to repeat myself.