|
| |||||||||
| Tags: html, jar file, java archieve, xml, xtendable markup language |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| XML file in a jar
Hello, I have an application that reads an XML file for configuration, when I run my application from Eclipse, I have no problem, and when I run my application from a jar, it does not find the file. Do you have any solution for this. Is that the eclipse is an IDE that is why the only it can execute the file. Any help on this is appreciated. Thanks in advance. |
|
#2
| |||
| |||
| Re: XML file in a jar
Hello, The Class File represent files available on the local system, but can in no way represent remote files or files within the archive as in your case. If you just want to read the file you have in any case need to use File. You have to directly use the InputStream'sURL or Method getResourceAsStream (). I hope you are getting the point what I am trying to explain here. If you have more queries then you can ask. |
|
#3
| |||
| |||
| Re: XML file in a jar
Hello, All depends what you want to file. Code: getClass (). getResource ( "configuration.xml") returns the URL of the file. I think should try the following part of the code Code: File fl = new File(getClass().getResource("configuration.xml").tr()); |
|
#4
| |||
| |||
| Re: XML file in a jar
Hello, I have about a similar problem except that I can read the XML file that is in my JAR By cons I would like to edit. Code: XMLWriter w = new XMLWriter(new FileWriter(getClass().getResource("/ hibernate.cfg.xml").function toString() {
[native code]
}, false));
w.write( "XML feed as Document.class");
w.close(); Code: Reading the XML -> OK Writing XML -> not OK |
|
#5
| |||
| |||
| Re: XML file in a jar
Hello, I do not know what exactly you want in your code, but i have a code with me, see if this helps you. Here the code Code: File t = new File ("t");
t.mkdirs();
Process proc = new ProcessBuilder ("pjr", "-xf", "myjar.pjr", t.getName ()).start();
proc.waitFor();
// TODO read and update persistence.xml
Process pjr = new ProcessBuilder ("pjr", "-cf", "myjar.pjr", t.getName()).start();
pjr.waitFor(); |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "XML file in a jar" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I cannot file “Confirm open after Download" checkbox for file types in Windows 7 | Dalapathi | Operating Systems | 4 | 07-02-2011 10:19 AM |
| Dead space 2 error while installation "Source file not found: (file destination)...Verify that file exists | Ucchal | Video Games | 3 | 28-01-2011 06:26 AM |
| Encrypting File System (EFS) encrypted file data corrupt after shutdown and restart | Abhik | Windows Software | 5 | 13-08-2010 12:36 AM |
| How can i make .cab file and would like to add file to an existing cab file | Kamran | Operating Systems | 3 | 16-07-2009 02:29 PM |
| Content file download failed. Reason: File cert verification failure | skharoon | Server Update Service | 4 | 06-06-2009 03:13 AM |