Read/Write Jar files?

This is really a newbie question, but since there's a forum specifically for jar questions I figured it was better to start here and move it to the newbie section if y'all deem it appropriate.
I have written a desktop application using Java 1.4.1 class libraries and intend the application to run on multiple platforms including Mac OS X, Windows XP and Linux. The application works standalone (not yet jarred) on the machine it was developed on, but now it's time to begin figuring out the distribution method.
Right now, the application reads several files from a flat text-file database, allows the user to peruse and display the information in a variety of ways, and gives the user a method to add to the flat-file database as needed. The file is about a megabyte and is excerpted into memory at initialization, then not referred to again unless the user writes additional data. When the user generates new data, write traffic to the file is fairly light, maybe 2-3kbytes per session.
I searched the forums for the best way to handle read/write data files for distribution and so far I haven't found anything that seems relevant, but surely the question must have been asked and answered before - maybe I'm using the wrong keywords?
Anyway, I have three basic questions:
1) Can I both read and write a file that's enclosed in a jar file? Or are files read-only once "jarred"?
2) Assuming I can both read and write a file within my jar file, is reading and rewriting within the jar so inefficient as to make that a non-preferred approach?
3) How do other folks who have a local read/write datafile in a desktop application deal with distribution? Keep the read/write datafile within the jar? Make a copy of it outside the first time the application is run and always read/write the copy outside the jar? Or some other strategy?
Thanks for any suggestions you can give a newbie at the Java game.
Jon

Thanks, that was pretty much what I suspected.
I have several data files and configuration files for this project, so I was trying to make the distribution as clean as possible. At least some of the config information can be hidden in Preferences, but I was struggling with the data files. I'll include the data files in my jar, then unpack them to the user's directory when launched the first time and work with them thereafter in the user's directory.
Enjoy the Dukes!
Jon

Similar Messages

  • Why can't I open read/write rules file?

    I have followed the Cookbook XML tutorial exactly as prescribed, even down to using all the examples from the 'Completed' folder, but when I try to perform any procedure such as generating a EDD or reading an XML instance (the ColorDoc.xml example) I get the following in the log file:
    Could not open the read/write rules file
    (App\ChapterReadWriteRules)
    Make sure you have read access to the file and that
    the file is not already in use.
    Using XP and Framemaker 7.
    Its a real blocker this proble. Have tries unsetting the XP Read-only folder property on all the folders in the heirarchy but XP won't let me do that. Very grateful if anyone could help me over this problem.

    What is the path you mentioned the structapps.fm file for read/write rules
    It should be full file path for read/write rules(including extension of file). Otherwise there is possibility of throwing the error you mentioned.
    Would it be possible to paste your XML application defined in your structapps.fm file??
    Thanks
    Basav

  • How to to read/write GIf files (not animated)

    Hi,
         Is there a labview vi(s) that will read a gif file and display it and also that will wirte it? I am interested in non animated gifs.
         Louis

    Ben wrote:
    Well before Mike got carried away in this thread the answer to those questions was "NO".
    But if you check that thread you will see that Mike has already done half of the work (reading a gif).
    There is limited functionality for writing a GIFin LabVIEW, look in vi.lib\picture\gif.llb\Write GIF File.vi
    Message Edited by Phillip Brooks on 10-09-2008 04:24 PM
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • How can I read/write data files (text file) from PL/SQL Script

    I had an oracle forms pl/sql program to read/write a data file (text file). When this code is run on a command line as a PL/SQL script using the SQL*Plus I am getting an error:
    -- sample.sql
    DECLARE
      vLocation                 VARCHAR2(50)  := 'r:\';
      vFilename                 VARCHAR2(100) := 'sample.dat';
      vTio                   TEXT_IO.FILE_TYPE;
      vLinebuf               VARCHAR2(2000);
      vRownum               NUMBER        := 0;
      -- use array to store data FROM each line of the text file     
      TYPE           array_type IS VARRAY(15) OF VARCHAR2(100);
      vColumn      array_type := array_type('');
      PROCEDURE prc_open_file(p_filename IN VARCHAR, p_access IN VARCHAR2) is
      BEGIN
        vTio := TEXT_IO.FOPEN(vLocation||p_filename,p_access);
      EXCEPTION
        WHEN OTHERS then
          --  raise_application_error(-20000,'Unable to open '||p_filename);
          message(sqlerrm);pause;
      END;
      PROCEDURE prc_close_file is
      BEGIN
        IF TEXT_IO.IS_OPEN(vTio) then
           TEXT_IO.FCLOSE(vTio);
        END IF;
      END;
    BEGIN
      --extend AND initialize the array to 4 columns
      vColumn.EXTEND(4,1);
      prc_open_file(vFilename,'r');
      LOOP
          LTEXT_IO.GET_LINE(vTio,vLinebuf);
          vColumn(1)  := SUBSTR(vLineBuf, 1, 3);
          vColumn(2)  := SUBSTR(vLineBuf, 5, 8);
          vColumn(3)  := SUBSTR(vLineBuf,10,14);     
          Insert Into MySampleTable
          Values
            (vColumn(1), vColumn(2), vColumn(3));
          EXIT WHEN vLinebuf IS NULL;
       END LOOP;
       prc_close_file;
    END;
    SQL> @c:\myworkspace\sql\scripts\sample.sql;
    PLS-00201: identifier 'TEXT_IO.FILE_TYPE' must be declaredIt works on the oracle forms but not on the SQL*Plus. Is there an alternative method using a PL/SQL script? A simple sample would help. Thanks.

    Did you ever noticed the search box at the right side of the forum?
    A quick search (limited to this years entries) brought up this thread for example
    Re: UTL_FILE Examples

  • Lion server file sharing issue with windows API read/write ini file (GetPrivateProfileString)

    Hello,
    I try to config lion server as file server for a windows application we use at work. All other computers are windows 7 or XP, lion server is the only mac. I choose lion server because it's size, quality and personal love of apple products.
    10.7.2 lion server's samba file sharing works almost perfectly with all my windows machines, I can copy, delete, modify any text files or office files without any issue, but the most important windows application for my business doesn't work with samba file sharing. After some digging, I found it is because windows program can't read or write INI file stored on lion share. Windows API GetPrivateProfileString always returns empty if the INI file is store on lion share.
    You can download a small application for read/write windows INI file from codeproject.com to test this problem:
    http://www.codeproject.com/KB/files/ini.aspx
    I can open/edit the in file using any text editor without any problem. The only problem is with those windows APIs. ACL is turned on for my lion share and assigned "delete" rights to samba users.
    I install samba3 on the same server; it works perfectly with windows API. My windows program also works. Looks like there is something wrong with lion server's sambax.
    I'd prefer to use built-in samba even I have samba3 working. Built-in samba is very immature right now, but considered how young it is, I will give apple some time to make it mature.
    Does anyone have same issue or knows how to fix it?
    Thanks,
    Michael.

    All the memory is fine. The server rarely if ever goes down when there are only around 10-12 users connected. When there are 20+ users connected and working heavily it goes down often. When I say working heavily, I mean they are transferring huge files to the SAN (100GB+), sometimes 5 at a time per user, and there are a bunch of others who are reading large video files at a minimum of 220MB/sec from the SAN.
    Though this worked on Snow Leopard without any issues, Lion just doesn't seem to be able to handle it. The odd thing is, on Snow Leopard there was only a single 1GB ethernet connection to a NAS system, whereas with Lion we have a much more powerful machine with a 6-port 10GB ethernet card and a 4 lane 8GB fiber card to a true SAN. You would think that the newer scenario with Lion would handle far more users with ease.
    So far, very disappointing with regards to Lion's file serving performance.

  • Read-Write ABF-Files

    Hello!I wish to write the program allowing to read and write abf files. For this purpose on a site http://www.moleculardevices.com/home.html has downloaded library dll - Axabffio32.dll. The problem following - how with Call Library Function Node to describe function ABF_ReadOpen:
    #include "abffiles.h"BOOL ABF_ReadOpen( char *szFileName, int *phFile, UINT uFlags,ABFFileHeader *pFH, UINT *puMaxSamples,DWORD *pdwMaxEpi, int *pnError );Opens an existing ABF data file for reading. Reads the acquisition parameters from the file header into the passed ABFFileHeader structure.Parameter szFileName Name of data file to open. phFile Pointer to ABF file handle of this file. uFlags Flag to indicate whether file is parameter file or not. pFH Pointer to acquisition parameters read from data file. puMaxSamples Pointer to requested size of data blocks to be returned. pdwMaxEpi Pointer to number of sweeps that exist in the data file. pnError Address of error return code. May be NULL.
    The ABF_ReadOpen function opens the data file szFileName, allocates an ABF file handle for it and assigns this number to *phFile. Data is read from the file header into *pFH. If ABF_PARAMFILE is set in uFlags then no further processing is performed, otherwise internal buffers are allocated in preparation for file reading.For ABF_GAPFREEFILE and ABF_VARLENEVENTS files, *puMaxSamples is passed in as a requested maximum size of the blocks of data returned by the ABF_ReadMultiplex and ABF_ReadChannel routines. For all modes, the actual value that will be used is returned in this location.For Event Detected modes, on calling ABF_ReadOpen, the parameter pdwMaxEpi points to a the maximum number of sweeps to read from the file. If it is zero the maximum will be 8192 sweeps, depending on RAM availability. The total number of data blocks of the size returned in *puMaxSamples is returned in *pdwMaxEpi.
    I try do it as
    int8_t ABF_ReadOpen(CStr *szFileName, int16_t *phFile, uint16_t uFlags, int32_t *pFH, uint16_t *puMaxSamples, int32_t *pdwMaxEpi, int16_t *pnError );
    But it's not working.
    Thanks. 

    Hello!I wish to make record abf-files, therefore variants of the program which has sent srikrishnaNF me do not arrange.I have decided not to work with dll, and have found as is written abf a file as bytes. As it is told in the description the data are written in a format "as multiplexed two-byte binary integers". What does it mean? I have written the program which reads out on two bytes from a file and translates them in type single, but I do not find numbers which are written in a file (read this value with OriginLab).
    Attachments:
    Search value.vi ‏101 KB
    ABF Structure.JPG ‏158 KB
    Data Structure.JPG ‏142 KB

  • Read/Write App Files Under Limited User Account

    Hi All,
    My desktop app is intended for Windows only. I'm writing files to the hard disk to store app specific configuration.
    The applications main data source is a ZIp file that consists several XML files. The user can store this ZIP anywehre they like and the application will extract the necessary files to a temp dir so that it can read in data.
    When logged into a PC as either an Administrator or Power User, I am able to read write my config files and extract XML files from the ZIP with no problem.
    When logged in as a user with "limited" access, I can only read and write the config files. But when I go to extract any XML files from the ZIP, it seem to get denied due to insufficient permissions.
    The working directory for storeing all these files is: C:\Documents and Settings\<USER NAME>\Application Data\<MY APP>\
    Don't users with limited access have full read/write permissions to their own home directory?
    If not, what can be done to give them full read write access? Is there perhaps some other location I should be using?
    Also, would code signing from some place like Verisign do any good?
    I'm targeting Windows 2000/XP.
    Thanks in advance.
    Regards,
    Jim

    You can also access the user folder through the registry:
         public static final String APP_DATA_FOLDER_CMD = REG_QUERY_UTIL
              + "\"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\"
              + "Explorer\\Shell Folders\" /v AppData";
          * Gets the current user Application Data folder path defined in the
          * registry.
          * @return The current user Application Data folder path.
         public static String getCurrentUserAppDataFolderPath()
              return queryREG_SZ(APP_DATA_FOLDER_CMD);
          * Performs the query in the registry for the specified value type.
          * @param queryString The query to be performed.
          * @param valueType The value type.
          * @return The value data for the specified value name in the registry.
         public static String queryREG_SZ(String queryString, String valueType)
              try
                   Process process = Runtime.getRuntime().exec(queryString);
                   StreamReader reader = new StreamReader(process.getInputStream());
                   reader.start();
                   process.waitFor();
                   reader.join();
                   String result = reader.getResult();
                   int p = result.indexOf("REG_SZ");
                   if (p == -1)
                        return null;
                   return result.substring(p + valueType.length()).trim();
              catch (Exception e)
                   return null;
         }This will get you the user directory from the registry. However, my issue is
    that the value returned was:
    C:\Documents and Settings\<USER NAME>\Application Data
    Which is great, but that folder didn't exists on my computer. I cannot find
    any documentation to say why it would be there. Except I had no Application
    Data folders under any user. I have XP.
    So when running the program on one computer, I had no valid folder to write
    to and it wouldn't let me create it. Said the <USER NAME> folder could not
    be written to. canWrite() returned false and the directory could not be
    created.
    On another computer, I had the Application Data folder, the canWrite()
    returned false, yet I was able to create a folder and file inside.
    I checked the default <ALL USERS> directory and the Application Data folder
    did not exist there.
    I don't understand how I am supposed to work around it...
    If the folder doesn't exist, I need to be able to create it, whether it's in the
    <ALL USER> or <USER NAME> folder.
    I guess I am counting on the canWrite() to be accurate. Yet it appears that
    I cannot rely on the canWrite() since a false was returned. I wrote!!
    So confused ... need to be able to write to this folder on any computer...
    Help!!

  • Problem reading a jar file ?!

    Hello,
    I am having a problem finding a class file which is inside a jar(xercesImpl.jar) which is in the classpath. I cant figure out what the problem.
    I suspect it could be because my JVM is not reading the jar correctly.
    When i click on a jar, a dialog box titled "java virtual machine launcher" saying "failed to load main-class manifest attribute .." is displayed.
    Is it that there are executable and non-executable jars, and JVM will execute only the former ones ?
    Or Does this mean somethign is wrong with my JRE/JVM??
    i also tried typing "jar t xercesImpl.jar" (to see if it can print the table of files) and it doesnt do anything, doesnt even return to the prompt.
    I am on win xp and few days back downloaded jdk1.5.0 and uninstalled previous jdk.
    it seems windows has its own jre. i am bit confused which is being used.
    i m a Java newbie, so please forgive my ignorance. Any help appreciated.
    Thank you.

    Hello,
    Well seems you are going through the horror of creating application jar file from command prompt. I went through the same and finally decided to make it through jBuilder. But the trouble persisted and I was getting same error as you were getting till I explicitly specified all the third party jar files I was using in the classpath and the problem was solved.
    I recommend you to explicitly set all the jars in classpath that are being used by your application. Also set the path of any resources if you have any.
    All the best.
    Hemanshu

  • Reading nested jar files

    How to read and display contents of nested jar files
    Let the jar format is something like this.
    Parent.jar
                child11.png
                child12.xml
                child13.jar
                            child21.png
                            child22.xml
                            child23.jar
                 -

    You need to play around with classloaders to do it, and unless you know how to do this, there's little point someone giving you the code to, since you won't be able to debug it

  • Reading/Writting server files?

    Hello guys!
    I'm making an application with java web start.
    I need to read and writte a xml file, located in the same machine that i have the jar files and jnlp file (file located at the server, not in the client machine).
    When i tried to do a FileOpen, i catch an error "file open denied", and the file is in the server side!
    I have read in forums there is a security problem for reading local files, files int the client side, but if i try to work with files located in the server side , there are security problems too? I need to sign the jar equally? Any question more?
    Thanks for the help!
    null

    ...i have read by internet that not is possible to download
    any file not included in the jar file. Try 'my' internet - dietz333 says..
    http://forum.java.sun.com/thread.jspa?threadID=5173345&tstart=10
    "..in JDK 6 - Java Web Start added the feature of being able to download and use jar files that are not listed in the jnlp file. (An untrusted app can only download from the same host, but a trusted app can download from anywhere)."
    That is to download - reading files from
    the server.
    That so, the response for me is "not is possible to
    manipulate a file in the server"
    Curiosly, it's possible manipulate files from local disk,
    but no files included in the same directory of the server.
    Reading files from a server, is a very different
    thing to writing them to the server.
    Think about ..
    - if a competitor changed your application for
    a joke app. - or one that redirects users to a
    porn site..
    - if an attacker decided to take the site out
    by sending Gbytes of data to it!
    The server must look after itself, and it does
    so by implementing security against people
    uploading things (as well as limiting what
    they can read).
    For writing the file back to the server..
    I will try now to do a ... ftp put. I think that it's
    possible to do this in java web start?If you can do that from the command line -
    it is possible to do it in web start.

  • Unable to read/write Windows files on mac anymore

    Today, out of much extreme panick as of a false alarm, i had installed MacFUSE, an application used so you can read and write windows files on your mac side. What i didn't know is that i already had NTFS-3G, one which could already do that. I uninstalled MacFUSE instantly (removed pane from system preferences), now i still can't see windows mounted on my mac desktop. When i boot up, i get an error; below. If i choose to manually mount it from the disk utility i get the same error. I'm not sure where to post this type of stuff since it's not really apple related but it's worth a shot.

    I've had that same issue with NTFS-3G and Fuse. I ended up getting Paragon NTFS for Mac. Its about 20 bucks, but it works great. IMHO, this is a feature Apple should build into OS X especially since they have a feature such as Boot Camp

  • Read&write Excel file using java

    Hi everybody,
    I have an assignment about methods that read and write an excel file using java (Eclipse SDK), so if anyone know about that please post the solution as soon as possible.
    Thanks
    Sendbad

    http://onesearch.sun.com/search/onesearch/index.jsp?qt=read+write+excel&subCat=siteforumid%3Ajava31&site=dev&dftab=siteforumid%3Ajava31&chooseCat=javaall&col=developer-forums

  • Reading a jar file into a string

    I have a jar file that I want to open and read the contents into a string object. How do I do this ? Can someone post a sample code.
    Thanks you so much
    bala

    I hope you mean you want to get the contents of a file in a jar file and put in a string?
    You would create a URLClassLoader for that jar file, and call
    getResourceAsStream, and then treat it like anyother file to load into a string.

  • Read/Write text files in LabVIEW

    We have developed an instrument control and data acquisition system for a mass spectrometer using LabVIEW FPGA. Currently we have 6 counters on the FPGA, counting for 1 second intervals and transferring data to the host using a FIFO. 
    The data, as a local variable, is used in several different parallel loops on the host. One of these is coded to write the data to a text file. Unfortunately everything we have tried has failed. It is proving impossible using either the write to file VI provided with labVIEW, or to use the Open file, write and close file utilities. Each attempt has failed. Yet when running a dummy code we can write to files. The dummy code consists of 6 random number generators running in one loop and the write to file VI in a second loop. The random numbers are transferred across the loops as local variables.
    Can anyone offer any advice as to what we might be doing wrong. We're beginning to feel as though we are banging our heads against a brick wall and getting very frustrated.
    Many thanks in advance for any suggestions.

    Hi Paul,
    you neither say, what is failing nor do you show any code... How should we help then?
    "impossible using ... the write to file VI"
    Well, usually they work just fine.
    "Each attempt has failed."
    In which way? Error number given? Did you use the debuging tools, like probing, breakpoints and highlighting?
    "as local variables."
    It seems you're not properly do program "real" LabVIEW code
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Read / Write Excel file using package dbms_util and util_files

    hi,
    i am beginner to this so please elaborate the answer more concisely

    there's a ton of reading on this subject on google my friend.
    http://www.google.co.uk/search?hl=en&source=hp&biw=954&bih=517&q=plsql+read+write+excel&btnG=Google+Search&aq=f&aqi=&aql=&oq=plsql+read+write+excel
    and check the forum faq, there's a topic on excel in here:
    SQL and PL/SQL FAQ
    Edited by: smon on Mar 2, 2011 3:39 AM

Maybe you are looking for

  • Varinat configuration copy of batch characteristics from Sale order to production batch

    hi experts , below is the scenario : the characteristics and its value which are maintained in the sale order must be copied to batch produced during process order GR . it was not available in 4.7 but availbale in ECC 6.0 i guess by SAP. i have creat

  • Printer compatability

    I have a Surface Pro 3.  I use aa 1536dnf at work and an 8620 at home. Occasionally, I can only print from "Print Test Page." To get it to work from Office, QuickBooks, and the internet, I have to delete bothe printers and the associated software and

  • Network selection

    I have two desktops, 2 labtops on a network. I have created a network WDS with the new Extreme as a base. Everytime I go to use one of my desktops I need to select the network name I have created from the top toolbar rather than have this network be

  • Problems installing Kanaka

    I am trying to install Kanaka 2.7.0 on a SLES11SP2/OESSP1 server and keep getting an error. I am logged in to the server as the root user, but get the following message when I try to install: Failed to install file You don't have the necessary privil

  • Cannot download photos from Kodak Z612 using new Photos

    I had no problem downloading photos from my Kodak Z612 camera using iPhoto. Now I cannot download anything using the new Photos or Image Capture. As in earlier posts, re. iPhoto April 2014, I get a list of the .jpg photos that I wanted to import and