with a program im writing i need to move class files into a jar but i cannot figure out how to use the jar file as a directory. how can i access the contents of the jar file to move the files in there?
Printable View
with a program im writing i need to move class files into a jar but i cannot figure out how to use the jar file as a directory. how can i access the contents of the jar file to move the files in there?
If you mean you want to write a program that can put class files into a jar, check out the java.util.jar package. Alternatively, you could use Runtime.exec(..) to execute the Java jar tool (jar.exe).
If that's not what you mean, please explain in more detail.
how do i tell it which jar to use the input stream on?
Strange question. You use input streams on the file you want to read from.Quote:
how do i tell it which jar to use the input stream on
What is the "it" in that question?
Your original question didn't say how many jar files were involved in your project.
Can you explain what you are trying to do?
sorry you're right that i was un-clear. there is only one jar file that needs the patching i have a set of class files that are downloaded from a repo on the internet and then moved into the jar file. im using the fileinputstream on the class files that was downloaded a jaroutputstream (i think) on the jar that needs the files moved into. im wondering how do i choose the location of the jar and in the jar for where i want to move the file to?
You could use JFileChooser to choose the location and the jar.Quote:
im wondering how do i choose the location of the jar and in the jar for where i want to move the file to
one more thing when i choose the location of the jar and where in the jar i want to move the file can i use mkdir, createnewfile, and exists methods on those paths or is there special jar methods that provide the same function
also the jar that needs patching is in a set location. i just want the user to push one button and all files are downloaded and moved to the jar.
If you're not sure how to use the File class, write a small test program and experiment with the different methods to see what they do.Quote:
can i use mkdir, createnewfile, and exists methods