Results 1 to 8 of 8
  1. #1
    mniz13 is offline Member
    Join Date
    Jun 2011
    Location
    Boston, MA
    Posts
    7
    Rep Power
    0

    Default accessing xml files created during runtime

    I'm trying to run a script that creates an xml output file each time it is run and then access that xml file as soon as the script has stopped running. I am using the exec() method to run the script, which works fine. The issue I'm having is that the output files don't appear (in browser) until the execution of java is stopped. I have tried using the Thread.sleep() method in case the script wasn't finishing entirely, but it seems that no matter how long I wait, the xml file is only created when the java program stops execution. Is there any work around for this?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    the output files don't appear (in browser) until the execution of java is stopped.
    Do you close the file after you are finished writing to it?

  3. #3
    mniz13 is offline Member
    Join Date
    Jun 2011
    Location
    Boston, MA
    Posts
    7
    Rep Power
    0

    Default

    well the file is created by a different jar that is run through a script from the exec() command. It is created instantly when the script is run from the command line, but when I run it using the exec() command, the file is not created until the java stops running.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    the file is not created until the java stops running.
    Does the java program close the file after it finished writing to it?

  5. #5
    mniz13 is offline Member
    Join Date
    Jun 2011
    Location
    Boston, MA
    Posts
    7
    Rep Power
    0

    Default

    I don't have access to the jar file that is run through the script. Everything runs smoothly from the command line, so I assume it closes it, but I don't know.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    Sloppy programmers leave it to the java program to close files when the program ends. If the program keeps running for some reason, the file may not be fully written out until the program ends.

  7. #7
    mniz13 is offline Member
    Join Date
    Jun 2011
    Location
    Boston, MA
    Posts
    7
    Rep Power
    0

    Default

    I have a waitFor() after the exec(). Would that ensure that the jar stops running? Is there any way to end the program either in the .cmd script or using the Runtime class?

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    Read the API doc for the Runtime and the Process classes. See if there are any methods that will do what you want.

Similar Threads

  1. load jar files created with tbc
    By Inbarb in forum Eclipse
    Replies: 0
    Last Post: 02-27-2011, 07:14 AM
  2. Replies: 17
    Last Post: 11-22-2010, 08:43 PM
  3. Need help with accessing files in a method
    By t0nydanzuh in forum New To Java
    Replies: 6
    Last Post: 10-03-2010, 06:05 PM
  4. can you tell how transfer a List eg. created as...between files jsp/java
    By lse123 in forum JavaServer Pages (JSP) and JSTL
    Replies: 21
    Last Post: 02-10-2010, 08:52 AM
  5. Accessing index.dat files
    By vissu007 in forum Networking
    Replies: 1
    Last Post: 07-01-2007, 04:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •