actually i am coding a small tool. i am using ide eclipse. there i have built a project with a few classes and in the root of the project there is folder containing several .txt files. if i read them with my application in eclipse, there is no problem. but then i built a jar file (using fat jar plugin for eclipse). now the tool can not find the .txt files anymore (even if they are present in the jar-file). i looked up the internet for a solution but could not find anything.
can someone please help me?
controller.Application.java --> uses another class "InOut"
io.InOut.java --> this one acceses the files in the folder below
sql_templates/ --> Folder sql_templates/generateCode.txt ---> many files like this
thanks a lot kilia
Joined: Oct 13, 2005
Try putting the jar file into another folder, unzipping it and exploring its file structure to make sure the folders are where you want them.
I went into Eclipse->help and looked for jar files and this is what comes up
Creating a new JAR file
To create a new JAR file in the workbench:
1. In the Package Explorer, you can optionally pre-select one or more Java elements to export. (These will be automatically selected in the Opens the JAR export wizard JAR Package Specification wizard page, described in Step 4.) 2. Either from the context menu or from the menu bar's File menu, select Export. 3. Expand the Java node and select JAR file. Click Next. 4. In the JAR File Specification page, select the resources that you want to export in the Select the resources to export field. 5. Select the appropriate checkbox to specify whether you want to Export generated class files and resources or Export Java source files and resources. Note: Selected resources are exported in both cases. 6. In the Select the export destination field, either type or click Browse to select a location for the JAR file. 7. Select or clear the Compress the contents of the JAR file checkbox. 8. Select or clear the Overwrite existing files without warning checkbox. If you clear this checkbox, then you will be prompted to confirm the replacement of each file that will be overwritten. 9. Note: The overwrite option is applied when writing the JAR file, the JAR description, and the manifest file. 10. You have two options: * Click Finish to create the JAR file immediately. * Click Next to use the JAR Packaging Options page to set advanced options, create a JAR description, or change the default manifest.
See whether No 4 is of any use to you; I think your text files count as a "resource" to export.
The Java Tutorials have a section about jar files; try the link to updating a JAR file.
Joined: Aug 10, 2005
How does your "tool" find the .txt files? Are you using the getResource() method? This uses the classloader which knows how to find things in a jarfile, in a folder/subfolder or on a server.
Since jar files are VERY similiar to zip files, you can look at the contents of a jar file by using a zip file reader like WinZip, you wouldn't have to extract contents to see what's there.