Problems creating file. Can't get resource path.

Hey, I'm new to Java with an Actionscript background and I'm using NetBeans IDE.
Now this comes with my basic lack of understanding for how Java works but I'm getting confused a lot so if someone could just steer me in the right direction I'd be very grateful.
Essentially I'm checking for a config file and if it's not there, I want to create a default one but the paths are messing me up. class.getResource seems to use the src or the build/classes dir? What's the relationship of these? If I put assets in the src folder should they be moved to the build folder or something like that?
The actual problem in code is that if I create a file, (config.xml) and put it in my src folder I can grab it using Main.class.getResource("config.xml"); Which is great but if the file's not there it throws an exception..
Now In actionscript I'd use the File class, which seems very similar to Java's. I'd pass in a literal for the filename "config.xml" and prepend a constant that gives the path of the apps storage directory. If the file's not there then the File.exists property == false.
What I need is to get the same path that getReresource("config.xml") outputs, but in a File and I can't do that with the exception being thrown because the file's not there.
Any help appreciated.. I can't read another blog full of different setups or face another Google page of results pertaining to different problems.
- Chris W

RoninStretch wrote:
Essentially I'm checking for a config file and if it's not there, I want to create a default one but the paths are messing me up. class.getResource seems to use the src or the build/classes dir?It looks relative to the classpath, as I recall.
What's the relationship of these? If I put assets in the src folder should they be moved to the build folder or something like that?NetBeans might do that for you. It's a reasonable thing for a build system to do.
You might be better off working without an IDE until you're more familiar with Java.
The actual problem in code is that if I create a file, (config.xml) and put it in my src folder I can grab it using Main.class.getResource("config.xml"); Which is great but if the file's not there it throws an exception..Actually I think getResource will return null if the resource isn't there. Are you not checking for null?
Now In actionscript I'd use the File class, which seems very similar to Java's. I'd pass in a literal for the filename "config.xml" and prepend a constant that gives the path of the apps storage directory. If the file's not there then the File.exists property == false.The Java File object refers to a path on the filesystem, not a virtual one in the manner of Class.getResource. Check the result of getResource to see if it's null.
What I need is to get the same path that getReresource("config.xml") outputs, but in a File and I can't do that with the exception being thrown because the file's not there.Can you show us the actual exception and actual code?
Anyway, if you're packaging all this up in a jar, you wouldn't put the new config.xml that you create in the jar anyway.
More likely you'd do something like:
1) check user's home directory for config.xml
2) if it's not present, check to see if there's a config.xml packaged in your jar.
3) if the user has any config changes, put them in a config.xml in the user's home directory.
So you wouldn't be trying to get the path of the default config.xml anyway.
Or maybe you can use the Preferences framework.

Similar Messages

  • How can i get the path to config folder placed inside the jar file?

    Hi i have developed an RCP application using eclipse.
    In my application config directory is there.
    When i export my RCP application as JNLP Project the jar file is created which contains config folder inside it.
    When i download the application using java web start , how can i get the path to config folder placed inside the jar file?
    Will the config folder exists in local cache in my system?
    Help needed.
    -Deepak

    -- This works in CS6:
    tell application "Adobe InDesign CS6"
      set myDocument to active document
      set selectedRectangles to selection of myDocument
      set theGraphicsLink to file path of item link of (graphic 1 of (item 1 of selectedRectangles))
    --> "Macintosh HD:folder/folder/filename.tif"
    end tell

  • How can I get the path of an existing file????

    Hi.
    I'm a newbie in Jsp development, so this question may appear trivial.
    How can I get the path into a String of an exixting file ..like ...
    String thepath = path_of("my file.txt");
    Thanks for your help.

    Try
    application.getRealPath("myFile.txt")

  • HT4914 Once I deleted my music files can I get them back via I cloud? I have Itunes match on.

    Once I deleted my music files can I get them back via I cloud? I have Itunes match on.

    I actually deleted my backup :-) That's the problem. But thanks.
    I've managed to get some back but via a slightly different method.
    Because the files weren't there, when I deleted them from my library they actually disappeared from the list.... So I created a new library (backed up my original one) and then synched that with Match so that all the files appeared. I'm just going through the ones I'm missing clicking 'download' and then when they're all back on my hard drive I'll revert to the previous Library which will hopefully pick up all of the recovered files.
    Bingo!

  • I don't want the 'chat' option. how can I disable it? I often get the message that I am being disconnected from chat because i've logged on from another computer. I never use chat, and it just seems to be a problem. How can I get rid of it?

    I often get the message that I am being disconnected from chat because i've logged on from another computer. I never use chat, and it just seems to be a problem. How can I get rid of it?

    Don't expect any wonders. If you use it heavily with multiple applications running at the same time, nobody can help you. It's physics: more usage => higher energy consumption.
    Here you can find some tips to reduce the battery consumption. My tip: close applications if you don't need them right now and reduce screen brightness.

  • I have a MacBook Air with OS X and am having trouble accessing the ADT Pulse Home Security System cameras.  The mobile (iPhone and iPad) apps allow access no problem, but I can't get a picture on the MacBook.  Have tried Safari and Firefox browsers.

    I have a MacBook Air with OS X and am having trouble accessing the ADT Pulse Home Security System cameras.  The mobile (iPhone and iPad) apps allow access no problem, but I can't get a picture on the MacBook.  Have tried Safari and Firefox browsers.  Anyone have any ideas?  Thanks.

    From a Catherine to Katherine -- Had the exact same problem!!  I had to enable Java twice - both in Safari and then on the MacBookAir itself.

  • I recently rented a movie from itunes (John Carter) and tried to move it to ipod but got message that it is not compatible. Why did this happen as I haven't had problem before and can I get money back?

    I recently rented a movie in itunes (John Carter) and tried to move it to ipod but got message that it's not compatible. Why did this happen as I haven't had problem before and can I get my money back?

    Are you sure you don't have a 5G iPod video?  If so, rented movies are not compatible with that particular generation/model of iPod.
    Otherwise, it sounds like the rental is in HD.  It should have came with a Standard Definition version instead.
    B-rock

  • I installed the new software onto my windows computer and then couldn't open it.  I did the uninstall and reinstall and I am still getting the same  problem.  How can I get my itunes back?

    I installed the new itunes software onto my windows computer  and then couldn't oopen Itunes.  I did an uninstall and reinstall and still have the same problem.  How can I get my itunes back?

    It says " application failed because MSVCR80.dll is missing from computer and then when I click okay it says I tunes wan't installed correctly Please reinstall
    Many thanks, that's perfect. Try the following user tip with those ones:
    Troubleshooting issues with iTunes for Windows updates

  • Unable to create File System Repository using Network Path

    Hi All,
    I am trying to create a File System Repository.
    I created a networkpath and windows system and used the same while creating File Repository according to the steps in help.
    With out using Networkpath(i.e.,If I use IP address,I am able to create File System Repository).
    But with the network path,it throws the following error as seen in Component Monitor.
    <b>Startup Error:    The localroot does not exist: C:\usr\sap\IGTE\j2ee\j2ee_00\cluster\server\NWP_001
    My network path is NWP_001
    </b>
    Did any one face this problem?
    Any help please........
    Rgds,
    Santhosh

    Hi,
    I am getting the same error even if I replace(\) by slashes(/).
    I tried on EP6SP12 as well as EP6SP2 and got the same error on both.
    The repository is searching for a folder named with
    n/w path on the portal server itself(i.e, it is searching in the following folder
    <b>C:\usr\sap\IGTE\j2ee\j2ee_00\cluster\server\NWP_001
    My network path is NWP_001</b>),instead of searching on the remote system.
    Can any one help me in solving the problem
    Thanks in Advance.
    Rgds,
    Santhosh

  • InDesign update CS5.5 won't open new file / can't get monitor RGB colors

    My biggest problem...a job to do a b&w booklet for a 50th class reunion ready for printer. Tried PS. Downloaded trial of Publisher, but haven't tried. Upgraded Creative Suite to 5.5 to use InDesign. Everything I set as prefs, formats, etc. as soon as I hit enter I get a full screen empty page and a cursor that twirls until I force quit. Do you know why? Do I need to uninstall the earlier version of CS? I should be done with this project and haven't begun. Should I just go to PS and create a tabloid format master and do it all manually? Should I try publisher? Can I get InDesign to work? My reputation is at stake and I want to get the job done rather than tell him this late that I can't do it!
    While trying to set the template for the book in InDesign, somehow I now only have 2 colors... blue and graphite, for my display of everything. Tried ColorSync, DigitalColor Meter, tried to find out what resolution to use, I'm lost! NEVER had these problems b4! Please help me ASAP if you know the answers!
    How will I know if someone answers?

    Does this happen with all CS4 files or just some?
    Do those files work in CS4/on other computers?
    Where are those files from?
    Are they perhaps on a networked drive? An USB stick?
    Can you save a new file and open that?

  • Create File Table for Existing UNC Paths ?

    Hi,
    I have a files with in the server ( //Server1/Folder1) and (//server1/Folder2).
    Now If I am create FileTable Database in the server ( server2 ) and how can I give filename path ?
    Example :
    I am going to create FileTableDB database in the server2 , it contains directory 'D:\'
    CREATE DATABASE FileTableDB
    ON PRIMARY
    (Name = FileTableDB,
    FILENAME = 'D:\Microsoft SQL Server\MSSQL\DATA\FileTable\FTDB.mdf'),
    FILEGROUP FTFG CONTAINS FILESTREAM
    (NAME = FileTableFS,FILENAME='\\Server1\Main\cfs')
    LOG ON
    (Name = FileTableDBLog,FILENAME = 'D:\Microsoft SQL Server\MSSQL\DATA\FileTable\FTDBLog.ldf')
    WITH FILESTREAM (NON_TRANSACTED_ACCESS = FULL,DIRECTORY_NAME = N'FileTableDB');
    GO
    If I run above query then I am getting an error is " cannot be used for FILESTREAM files."
    Please help me to solve this..

    Hi Narsa,
    The FILESTREAM data container for a database must be placed on an NTFS volume on locally-connected storage. Just like database data and log files, the directory cannot be on a UNC share. Even if you use UNC it will not work. FILESTREAM can be setup only
    for locally attached storage (locally for the server).
    There are more information about enabling and using FILESTREAM, you can review the following article.
    http://lennilobel.wordpress.com/2010/12/12/sql-server-2008-filestream-part-2-of-3-enabling-and-using-filestream-2/
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • How can I get the path name and rename it?

    I Hope someone who knows more about automator than I can help me out here. What I'm trying to do is get the path file name, while also changing part of it. Here is my example:
    I can get the path name with this "Get Path" script I found http://automatorworld.com/archives/get-path/all-comments/
    It does half the job so I just need to tweak it but know how. When I get the path this is what I'll get: /Volumes/Public/Creative Services/Campaigns/2010/NCDDiv-32CDV Upgrade/NCDDIV-32Versions.xls
    I need to remove the beginning part"/volumes" to "file://///nhmanmkt01"
    This is so I can send the path from our sever where we keep our files to my windows friends so they can open it.
    Thanks for any help you can provide!

    ok, make the following workflow.
    1. get selected finder items.
    2. run shell script
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #ADD8E6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    for f in "$@"
    do
    echo "$f"|sed 's%/Volumes%file://///nhmanmkt01%'
    done</pre>
    set the script to accept input as arguments
    3. copy to clipboard
    save it as a finder plugin.

  • I can not get my Adobe Photoshop Elements 8 organize to open. The edit option comes up with no problem, but will crash when I try to access organize. What should I do to fix this problem?I can not get my Adobe Photoshop Elements 8 organize to open. The ed

    I can not get my Adobe Photoshop Elements 8 organize to open. The edit option comes up with no problem, but will crash when I try to access organize. What should I do to fix this problem?

    Hi,
    Which operating system are you running on?
    Try starting the organizer while holding down the shift key.  Hopefully, it should load the Catalog Manager.
    Select your current catalog and click on the Repair button. Once it has finished, click on the Open button to see if the catalog opens.
    Good luck,
    Brian

  • Bursting Problem - A file or directory in the path name does not exist

    I'm trying to burst some data via email using the standard DocumentProcessor java code but receiving an error relating, I assume, to an invalid temporary directory. I've checked that the directory exists, as do the data file and control file. By the way I am not running in Apps, just stand alone mode. Any ideas would be much appreciated.
    [042308_104249440][oracle.apps.xdo.batch.bursting.FileHandler][EXCEPTION] java.io.FileNotFoundException: /u02/DIAS/bursting/BIPublisher/tmp/042308_104249338/xdo2.tmp (A file or directory in the path name does not exist.)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:205)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:96)
    at oracle.apps.xdo.template.RTFProcessor.setOutput(Unknown Source)
    at oracle.apps.xdo.batch.bursting.FileHandler.rtf2xsl(Unknown Source)
    at oracle.apps.xdo.batch.bursting.ProcessDocument.getXSLFile(Unknown Source)
    at oracle.apps.xdo.batch.bursting.ProcessDocument.processTemplate(Unknown Source)
    at oracle.apps.xdo.batch.bursting.ProcessCoreDocument.processLayout(Unknown Source)
    at oracle.apps.xdo.batch.BurstingProcessorEngine.addDocument2Queue(Unknown Source)
    at oracle.apps.xdo.batch.BurstingProcessorEngine.createBurstingDocument(Unknown Source)
    at oracle.apps.xdo.batch.BurstingProcessorEngine.burstDocument(Unknown Source)
    at oracle.apps.xdo.batch.BurstingProcessorEngine.globalDataEndElement(Unknown Source)
    at oracle.apps.xdo.batch.BurstingProcessorEngine.endElement(Unknown Source)
    at oracle.xml.parser.v2.XMLContentHandler.endElement(XMLContentHandler.java:196)
    at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1212)
    at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:301)
    at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268)
    at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:201)
    at oracle.apps.xdo.batch.BurstingProcessorEngine.burstingRequest(Unknown Source)
    at oracle.apps.xdo.batch.BurstingProcessorEngine.burstingEndElement(Unknown Source)
    at oracle.apps.xdo.batch.BurstingProcessorEngine.endElement(Unknown Source)
    at oracle.xml.parser.v2.XMLContentHandler.endElement(XMLContentHandler.java:196)
    at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1212)
    at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:301)
    at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268)
    at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:201)
    at oracle.apps.xdo.batch.BurstingProcessorEngine.burstingConfigParser(Unknown Source)
    at oracle.apps.xdo.batch.BurstingProcessorEngine.process(Unknown Source)
    at oracle.apps.xdo.batch.DocumentProcessor.process(Unknown Source)
    at PIreportburst.bEngine(PIreportburst.java:24)
    at PIreportburst.main(PIreportburst.java:51)
    -Below is the java code I'm using
    public void bEngine(String ctrlFile, String dataFile, String tmpDir) {
    try {
    DocumentProcessor dp = new DocumentProcessor(ctrlFile,dataFile,tmpDir);
    dp.process();
    catch (Exception e) {
    System.out.println(e);
    }

    Thanks Ike
    Where do you suggest setting the temp directory:
    DocumentProcessor("control.xml","data.xml","/u02/DIAS/bursting/BIPublisher/tmp/042308_104249338/xdo2.tmp")
    or in the xdo.cfg:
    <property name="system-temp-dir">/u02/DIAS/bursting/BIPublisher/tmp/042308_104249338/xdo2.tmp</property>
    ..and thanks for the link to the BIPublisherIDE
    Cheers, Mike

  • Queries: Problem creating file in background

    Hi,
    i am trying to create txt files in background with sap queries, but it doesn't work.
    In dialog mode it works but not in background. Path is my standard application server path /home/data/..
    Any ideas?
    Thanks!

    I have the same problem.
    On another thread, it said it's not possible to do in background.
    The File Store Option is only for execution in dialog mode.
    Can somebody confirm or inform it ?
    One solution is to activate an user exit!
    Implement the user-exit to download the results of standard queries (SQ01) to application servers, while being run in a background.
    First create a project, then use the enhancement assignment to include SQUE0001 SAP Query: Private data file. Further implement the user exit EXIT_RSAQEXCE_001 in the component section. Include ZXQUEU01 can have your code.
    http://sap.ittoolbox.com/groups/technical-functional/sap-dev/what-does-it-take-to-run-a-sap-query-in-the-background-mode-1258275
    Thanks,
    David de Limelette
    Message was edited by:
            David de Limelette

Maybe you are looking for

  • "I Need to Sign" options are greyed out in Reader

    I created a fillable form with Acrobat, including two fields where signatures are required. When I test the form within Acrobat (clicking on the signature field), I am prompted to create/insert a digital signature. But when I try the same thing in Re

  • Error while creating part appraisers using HRHAP_DOCUMENT_CREATE

    Hi All, I was able to successfully create a appraisal document by using HRHAP_DOCUMENT_CREATE function module. There was a additional requirement that part appraisser details also need to be updated while the document is created. I am getting an erro

  • Workbook funs from Disco Desktop but errors out in PLUS

    Hi, Let me start by saying that I read the previous thread on this topic from September 2008 but have not yet found a solution. There is an existing report of Unpaid Invoices that uses folders from Accounts Payable (AP Payment Schedules, Invoices, Su

  • JDBC sender Adapter consistency and Transaction level - URGENT

    Hi, We are using the JDBC adapter to read data from an Oracle view. The view joins two tables on their keys where flag = 0. The JDBC adapter carries out the select and then updates the selected rows with flag = 1. The transaction level used is the de

  • Assigning a "Job" to a User in the Org Structure

    Hi, I'm trying to assign a Job to a User in PPOMA but don't know where this data is created or maintained? (SRM 5) Any info would great. Regrds, S