Updating an XML file inside the executable JAR.

Hello all!
I would like to askk how can i update an XML file that is packaged inside my jar file?
For intstance:
I have a Java Application in NetBeans
Inside a package i have constructed a custom .xml file.
I can read from this file using
.....getClass().getResourceAsStream("/.../file.xml")and after that using XPath for querying and works fine.
I want to update an entry in my xml file so the jar contains now the newly updated file.
Thanks everyone who spends hit time to read this. Hope someone can help me.

Please don't cross-post:
http://forums.sun.com/thread.jspa?threadID=5342194

Similar Messages

  • Updating an XML file inside the Jar executable

    Hello all!
    I would like to ask how can i update an XML file that is packaged inside my jar file?
    For intstance:
    I have a Java Application in NetBeans
    Inside a package i have constructed a custom .xml file.
    I can read from this file using
    .....getClass().getResourceAsStream("/.../file.xml")and after that using XPath for querying and works fine.
    I want to update an entry in my xml file so the jar contains now the newly updated file.
    Thanks everyone who spends his time to read this. Hope someone can help me.

    Even if it were possible, it would be a bad idea. A jar file is something you deploy. It can be really hard to manage ongoing maintenance if the thing you deploy changes after you've deployed it.
    Just create a file, in an appropriate place given the user's OS, to hold data that changes after the jar has been deployed. Your application will still be in a single jar; it's just that the application will happen to create additional content outside the jar.

  • Including a jar file inside an executable jar file

    Is it possible to include a jar file inside another (executable) jar file such that the included file is part of the class path for the outer file? If so, how do you specify this in the classpath in the manifest?

    Russ_Bjork wrote:
    Is it possible to include a jar file inside another (executable) jar file such that the included file is part of the class path for the outer file?No. Actually, I suppose it would be possible if you do all the 'heavy lifting', but Java is not designed to handle Jars within Jars.
    What do you see as the advantage of doing that?
    Is your app. a rich client (e.g. Swing, AWT, SWT..)?
    Can you distribute the app. from a server or the internet?

  • How to update XML file from the program

    i am new in abap , and i have the following issue,so plz anyone who knows how to do it
    Background :
    An XML file is used as the datasource for a Flex Application. From time to time this requires updating with new staff details.
    i have already saved the xml file in the c drive with the name C:\AdvAC\AC1\bin-debug\assets\staff
    Requirement :  Write a Dialog transaction with the following text input fields.
    Reference Indicator.     (Char10)
    Staff No          (NUMC, Length 5)
    Name               (Char50)
    Room               (Numc, length 3)
    Phone               (Numc Length 7)
    Mail               (char30)
    in screen 100
    The transaction should also have an u201CUpdate Fileu201D button, which when pressed :
    1) Loads the file C:\AdvAC\AC1\bin-debug\assets \ into an ITAB.
    2) Inserts the data into the ITAB using the following XML format.
    <staff>
    <ref_ind> Reference Indicator.</ref_ind>
    <staff_no> Staff No </staff_no>
    <name> Name </name>
    <room> Room </room>
    <phone> Phone </phone>
    <mail> Mail </mail>
    </staff>
    all should be inside  <allstaff> </allstaff> tagsu2026.
    Writes the ITAB back to the file.
    thanx all

    this is what i have done but i dont know how to do the rest. i will apprecite any help from u.
    Edited by: man700s on Feb 16, 2010 6:58 AM
    REPORT  Z_XML_FILE_UPDATE.
    TYPES: BEGIN OF ts_staff,
             REF_IND(10)  TYPE c,
             Staff_No(5)  TYPE c,
             Name(50)     TYPE c,
             Room(3)      Type n,
             Phone(7)     Type n,
             Mail(30)     Type c,
           END OF ts_staff.
    DATA: t_staff TYPE TABLE OF ts_staff WITH HEADER LINE.
    DATA: w_staff Type ts_staff.
    DATA T_STRING TYPE TABLE OF STRING.
    DATA W_STRING TYPE STRING.
    call SCREEN 100.
    PERFORM upload_xml_file.
    PERFORM update_xml_tab.
    *PERFORM download_xml_file.
    MODULE USER_COMMAND_0100 INPUT.
    W_STRING = '<allstaff>'.
      APPEND w_string to t_string.
      loop at t_staff into w_staff.
      w_string ='<staff>'.
      APPEND w_string to t_string.
      if T_staff-Ref_Ind = 'X'.
      CONCATENATE '<Ref_Ind>' w_staff-Ref_Ind '</Ref_Ind>' into w_string.
      APPEND w_string to t_string.
      ENDIF.
      if T_staff-staff_no = 'X'.
      CONCATENATE '<staff_no>' w_staff-staff_no '</staff_no>' into w_string.
      APPEND w_string to t_string.
      ENDIF.
      if T_staff-name = 'X'.
      CONCATENATE '<name>' w_staff-name '</name>' into w_string.
      APPEND w_string to t_string.
      ENDIF.
    if T_staff-room = 'X'.
      CONCATENATE '<room>' w_staff-room '</room>' into w_string.
      APPEND w_string to t_string.
      ENDIF.
      if T_staff-phone = 'X'.
      CONCATENATE '<phone>' w_staff-phone '</phone>' into w_string.
      APPEND w_string to t_string.
      ENDIF.
      if T_staff-mail = 'X'.
      CONCATENATE '<mail>' w_staff-mail '</mail>' into w_string.
      APPEND w_string to t_string.
      ENDIF.
      w_string = '</staff>'.
      append w_string to t_string.
    ENDLOOP.
      W_STRING = '</allstaff>'.
      APPEND w_string to t_string.
    ENDMODULE.               
    Edited by: man700s on Feb 16, 2010 7:01 AM

  • Validating xml-files inside jar-files  for JWS

    I want to use xml-files inside a jar-file and want to validate them with dtd-files,
    located in the same jar-file. This does work, but only as long as the dtd-file is
    in the same directory as the xml-file.
    For example, I have no problem, with a DOC Type-statement like
    <!DOCTYPE questestinterop SYSTEM "ims_qtiv1p1.dtd" >
    With this statement, however, one needs an approprate dtd in every directory containing an XML-file of that type.
    If however i want to gather the necessary dtd's in a directory one (or more) levels above with a DOCTYPE-statement of the form
    <!DOCTYPE questestinterop SYSTEM "../ims_qtiv1p1.dtd" >
    I get error messages of the form
    java.io.FileNotFoundException: JAR entry Mikro/Marshall/BookQuestions/../ims_qtiv1p1.dtd not found in C:\Dokumente und Einstellungen\wreiss\Anwendungsdaten\Sun\Java\Deployment\javaws\cache\http\Dwiwi.upb.de\P80\DM~vwl08\DMOViSS\DMoviss_current\RMMikro.jar
         at org.apache.crimson.parser.Parser2.fatal(Unknown Source)
         at org.apache.crimson.parser.Parser2.externalParameterEntity(Unknown Source)
         at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Unknown Source)
         at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)
         at org.apache.crimson.parser.Parser2.parse(Unknown Source)
         at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
         at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(Unknown Source)
         at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
         at oviss.competenceCenter.XMLExpert.setElements(XMLExpert.java:245)
    though the dtd-file is in the parent-directory (inside the jar) and the unpacked xml-file can be successfully validated.
    Why does this happen. How can one use a single dtd for multiple xml-files (of the same type) in different directories?.
    Thanks
    Winfried Reiss

    In reply to myself, replacing the HTMLBrowser constructor with this;
    public HTMLBrowser()
                  URL url;
                  try
                       // Construct the URL
                       url= this.getClass().getResource('/'+dir+'/'+startPage);
                       setPage(url);
                  catch (Exception e)
                  System.out.println( "Problem setting help homepage");
                 setEditable(false);
                 addHyperlinkListener(new LinkListener(this));
            }made it work. This is because seemingly you need '/' at the start of the resouce's path and '/' as the separator, regardless of platform.
    I hope this helps someone else.
    John

  • How to read some files inside the jar

    Hi,
    I have an applet that runs with JWS. The user can input some information and then I need to show this information in a web page. As the application can be run offline, I cannnot use JSP�s to generate the web page. The information is saved in a xml file, so I use a xsl parser to generate the html code. The problem is that I have to include some javascript files (.js). I put these files inside the jar, but, how can I read these files, or how can I reference these files from inside the html page ?
    Thanks !

    You can use getClass().getResource(classpath)
    to get a stream version of the data from your
    jar file. If you need to put it in a file, you
    can write that stream to a file in a temp directory.
    classpath is the classpath of your js file

  • How can I fill structure from the line with contetnt of a XML file inside?

    How can I fill structure from the line with contetnt of a XML file inside?
    I have array of lines with XML documents inside. All XML's have the same structure.
    I need to fill array of structures (with the same structure like given XML's) from data of these XML's.
    How can I do this? I am trying Transformation with ora:parseEscapedXML, but receive error: "XPath expression failed to execute.
    Error while processing xpath expression, the expression is "ora:processXSLT("Transformation_1.xsl", bpws:getVariableData("ProcessedFiles"))", the reason is javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Could not find function: parseEscapedXML.
    Please verify the xpath query."

    Ive posted the new code but now I'm getting a FileAlreadyExistException error. How do I handle this exception error correctly in my code?
    import java.io.IOException;
    import java.nio.file.FileAlreadyExistsException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    public class MyDomParser {
      public static void main(String[] args) {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      try {
      DocumentBuilder builder = factory.newDocumentBuilder();
      Document doc = builder.parse("ENtemplate.xml");
      doc.normalize();
      NodeList rootNodes = doc.getElementsByTagName("templates");
      Node rootNode = rootNodes.item(0);
      Element rootElement = (Element) rootNode;
      NodeList templateList = rootElement.getElementsByTagName("template");
      for(int i=0; i < templateList.getLength(); i++) {
      Node theTemplate = templateList.item(i);
      Element templateElement = (Element) theTemplate;
      System.out.println(templateElement.getAttribute("name")+ ".xml");
      for(int i=0; i < templateList.getLength(); i++) {
      Node theTemplate = templateList.item(i);
      Element templateElement = (Element) theTemplate;
      String fileName = templateElement.getAttribute("name") + ".xml";
      Files.createFile(Paths.get(fileName));
      System.out.println("File" + ":" + fileName + ".xml created");
      } catch (ParserConfigurationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (SAXException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();

  • Java Files inside the jar file cannot be read or accessed through Eclpse

    The Java File inside the jar file of the eclipse cannot be accessed through the Eclipse . It shows error for the modules in the jar file .
    But when compiled with adding the jar files to the class path the compilation is successful .
    How can i browse through the files in the jar like going into the function definition .
    TIA ,
    Imran

    Open MPlayer OSX and show the playlist (command-shift-p) then drag the file into the playlist. Click the file in the playlist and click the "i"nfo button. What does it list for file, video and audio format?
    Not all of the codecs used in avi and wmv files are available for OS X so I'm guessing your file happens to be using one that isn't...

  • Create the executable jar's file

    Hi guys,
    I am working on java desktop's application where a user will be able to run the application by double click the executable jar file. I followed the description of "Creating and Deploying a Simple Archive to Your File System of the help. After creating the jar file and when I double click on jar file to run the application I got this error message "Could not find the main class. Program will exit". I was not also able to run the application on the dos command.
    Please help. I don't have any problem when I run from Jdeveloper 9.0.4. I have window XP professional.
    Your input will be very welcomed.

    OK open up your deployed Jar file in something like Winzip and have a look at the Manifest.MF in meta-inf\
    I've just created an executable JAR with a main class of mypackage1.Class1 and it all ran ok. Here's the manifest:
    Manifest-Version: 1.0
    Main-Class: mypackage1.Class1
    Created-By: Oracle9i JDeveloper 9.0.2So make sure your's is similar and your Main-class looks the same - e.g. does not say something like:
    Main-Class: mypackage1.Class1.class

  • How to read, write file inside the JAR file?

    Hi all,
    I want to read the file inside the jar file, use following method:
    File file = new File("filename");
    It works if not in JAR file, but it doesn't work if it's in a JAR file.
    I found someone had the same problem, but no reply.
    http://forum.java.sun.com/thread.jsp?forum=22&thread=180618
    Can you help me ? I have tried this for all night !
    Thanks in advance
    Leo

    If you want to read a file from the JAR file that the
    application is packaged in (rather than a separate
    external JAR file) you do it like this ...
    InputStream is =
    ClassLoader.getSystemResourceAsStream("filename");Better to use
    this.getClass().getClassLoader().getResourceAsStream();
    From a class near to where the data is. This deals with multiple classloaders properly.

  • Merging X XML files, sorting the resultlist and finally execute a distinct?

    I have several questions about an XSLT file that I should write:
    1� First, I get X paths to XML files. It can be 2, 3, 4, ... whatever a number. I don't know exactly the total amount of XML files.
    I need to merge them dynamicly to one resultset.
    2� Next, I need to sort them on a specific node (remark: every XML file has the same DOM tree)
    3� Finally, I want to distinct the values because some of the nodes are in file 1, 2, 3 ... So I don't want duplicates.
    I guess this is not possible in XSLT? I can't use Java, so it should be done using XSLT ;;;

    Have a look here:
    [http://www.jenitennison.com/xslt/index.html|http://www.jenitennison.com/xslt/index.html]
    under the "Sorting" and "Grouping" sections. Also consider using XSLT 2.0, which has built-in grouping elements which make the convoluted XSLT 1.0 techniques unnecessary.

  • Xml file with DTD in jar file

    Dear all,
    I developed an application using NetBeans which lets you create XML files.
    The process of creating the new XML file, set the attribute Doctype of these files to the DTD (fileXML.dtd) present in the build / classes / Dtd that is loaded during implementation through:
    URL url=ClassLoader.getSystemClassLoader().getResource("Dtd/fileXML.dtd");so the attribute Doctype XML files created will have the location of the DTD fileXML.dtd:
    <?xml version="1.0"?>
    <!DOCTYPE AGSet SYSTEM "file:/F:/Documents%20and%20Settings/ioXp/Desktop/mioProgramma/build/classes/Dtd/fileXML.dtd">
    Well. After completing the development of the program, I created the executable miaApplicazione.jar (in which he was pulled inside your full Buil, including build / dtd) by the option of NetBeans "Build Main Project."
    Double-clicking the file miaApplicazione.jar the program runs properly.
    The problem now is that when I create the XML file by mioProgramma.jar, they will refer to this DTD within miaApplicazione.jar and consequently when trying to open these files XML message appears:
    Protocol specified unknown. Error processing resource "jar:file:/F:/Documents%20and%20Settings/ioXP/...
    <?xml version="1.0"?>
    <!DOCTYPE AGSet SYSTEM "jar:file:/F:/Documents%20and%20Settings/ioXp/Desktop/miaApplicazione/...
    What is the solution for this problem?
    Hi
    ELVIO

    Hi swanelvis ,
    I have the same issue. Were you able to resolve this ?
    Thanks

  • How to update session.xml file

    any body have an idea about how to update the session.xml file using Toplink workbench Editor.
    I have an Jar file which contains the session.xml file , so i am trying to update the session.xml file with me database details.

    any body have an idea about how to update the
    session.xml file using Toplink workbench Editor.
    For 10.1.3, see "Sessions Configurations and the sessions.xml File" in the TopLink Developer's Guide: http://www.oracle.com/technology/products/ias/toplink/doc/10131/main/_html/sesun002.htm#CACIGEBC
    For 10.1.2, see "OracleAS TopLink Sessions Editor" in the TopLink Mapping Workbench Guide: http://download.oracle.com/docs/cd/B14099_16/web.1012/b15900/tscedit.htm

  • How do i wrap a dll inside an executable jar

    hi,
    i have an executable jar that uses jni to reference native code in a dll.
    i can launch the executable jar only if the dll is in the same directory as the jar (or in system32).
    so, i figured if i added the dll to the jar it would work. no!
    what do i do to deploy only 1 executable jar?
    thanks

    Hi anonimuds,
    I see useless &ldquo;expert&rdquo; activities here instead of giving a real response!
    You can pack a native library with bytecode if you use WebStart technology. Let look at the example tested by me. It shows Windows MessageBox from the native method.
    Here is Java class HellowWorld:
    package test;
    public class HellowWorld {
    static {
    System.loadLibrary("HellowWorld");
    public static void main(String[] args) {
    DoHellow();
    public static native void DoHellow();
    }With javah I generated C++ header:
    /* DO NOT EDIT THIS FILE - it is machine generated */*
    *#include <jni.h>*
    */* Header for class test_HellowWorld */*
    *#ifndef _Included_test_HellowWorld*
    *#define _Included_test_HellowWorld*
    *#ifdef __cplusplus*
    *extern "C" {*
    *#endif*
    * Class: test_HellowWorld
    * Method: DoHellow
    * Signature: ()V
    JNIEXPORT void JNICALL Java_test_HellowWorld_DoHellow
    (JNIEnv *, jclass);
    #ifdef __cplusplus
    #endif
    #endifWith MS Visual Studio I made a simple library with the native method implementation:
    #include "stdafx.h"
    #include "test_HellowWorld.h"
    BOOL APIENTRY DllMain( HANDLE hModule,
    DWORD ul_reason_for_call,
    LPVOID lpReserved
    return TRUE;
    JNIEXPORT void JNICALL Java_test_HellowWorld_DoHellow(JNIEnv *, jclass)
    MessageBox(0, "Hellow World!", "Message", MB_OK);
    }I compiled Java code above to test.HellowWorld.class and JNI code to HellowWorld.dll.
    Then I packed bytecode and DLL to HellowWorld.jar with batch file:
    %java_home%\bin\jar cvmf MANIFEST.MF HellowWorld.jar test/HellowWorld.class ./HellowWorld.dll
    %java_home%\bin\keytool -genkey -v -alias vitaly -keystore OlejaKeystore -storepass MyStore -keypass Caretta
    %java_home%\bin\jarsigner -keystore OlejaKeystore -storepass MyStore -keypass Caretta HellowWorld.jar vitallyWhere content of MANIFEST.MF is
    Manifest-Version: 1.0
    Created-By: 1.4.2_12 (Sun Microsystems Inc.)
    Main-Class: test.HelloWorldBefore deploying the project to Intranet Site I prepared JNLP and HTML files.
    The content of HellowWorld.jnlp file is
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="1.0+" codebase="http://vitallis/HellowWorld">
    <information>
    <title>HellowWorld Example</title>
    <vendor>ABC Ltd</vendor>
    <homepage href="HellowWorld.html"/>
    <description>JNI Test</description>
    <description kind="short">JNI Test</description>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.3+" href="http://java.sun.com/products/autodl/j2se"/>
    <j2se version="1.3+"/>
    <jar href="HellowWorld.jar" main="true" download="eager"/>
    </resources>
    <resources os="Windows">
    <nativelib href="HellowWorld.jar" download="eager"/>
    </resources>
    <application-desc main-class="test.HellowWorld"/>
    </jnlp>The codebase value you will change to URL of your Site. And at the last, here is HellowWorld.html text
    <html>
    <head>
    <title>Java Web Start Example</title>
    </head>
    <body>
    <P>Java Web Start Example:</P>
    <P>
    <a href="HellowWorld.jnlp">JNI Example</a>
    </body>
    </html>I have tested this project on my computer and it runs fine.

  • How to Save XML file in the same directory as the swf file automatically?

    Hi all,
    I'm really new here with flash and actionscript 3, so i might not make any sense, probably. Any input is greatly appreciated.
    So here's my problem, i'm trying to make a Top Score history for a flash game, which i load from an XML file. The problem comes to when i want to update the XML file. how do i do that automatically without prompting the user (ofcourse). I want it to be saved automatically to the same directory as the flash file.
    here's my code right now, but it prompts the user where it wants to be saved, which i don't want to happen:
    var xml:XML = <XML>
                        <topScoreList>
                        </topScoreList>
                  </XML>;
    for(var i:Number=0; i<10; i++)
         var Record:XML = <Record>
                             <score></score>
                             <playerName></playerName>
                        </Record>;
         Record.score.appendChild(topScores[i].toString()); //topScores[] -> class variable containing scores
         Record.playerName.appendChild(topNames[i].toString()); //topNames[] -> class variable containing names
         xml.topScoreList.appendChild(Record);
    var ba:ByteArray = new ByteArray();
    ba.writeUTFBytes(xml);
    var fr:FileReference = new FileReference();
    fr.save(ba, "topScoreList.xml");

    yeah that makes sense, actually - after reading a dozen more forums. It's really weird tho that flash doesn't have a Buffer writer, unlike other programming frameworks.
    But yeah, thanks. i'll start reading on flash.net.SharedObject, correct ? Thanks.
    Anyways, if anyone out there has a different input, will be greatly appreciated!!

Maybe you are looking for

  • KM WebDav URL is wrong

    Hi folks, I am working on a project to replace our existing EP 7.0 Portal, which relies heavily on KM for it's content, with an Enterprise Portal 7.0 in a cluster. I have built the new cluster system, "Portalnew" and then transported the System Lands

  • SOA11g: Transform Activity shows as Pending

    Guys, After migration of a process from 10.1.3.4 into 11.1.1.4, In many processes Transform/Assign activity always shows in pending state. Here is the xsl used in one of the Transform activity. *<?xml version = '1.0' encoding = 'UTF-8'?>* *<xsl:style

  • Importing from Target Photo CD

    So this is a little bit nit-picky, but when I import pictures from a Target Photo CD, it does not pull the original file from the CD, iphoto only makes an alias to the original file, which is on the CD. I know I can put a folder of those CD pictures(

  • Win 8 product key and a pre-installed Lenovo Ideapad Yoga 13, how to get it?

    Hello I live in Finland and I have read previously that these Windows 8 product keys are now linked somehow with motherboard´s BIOS systems, so we actually don´t need to know our product codes anymore. Well, in some cases we do need to know them. My

  • Wrinting into html

    Hello guys, I want to make a content management system. But to keep everything fast, I want to alter html pages automatically from my JSP pages... For example: I add a text in the admin to the database. Then I want to add this text to the index.html