Loading image files

I know this may be a simple question because i just started with java but whenever i am trying to load a jpeg or another picture
file for an ImageIcon or something i hav to type the file pathname i.e. C:/Users/Zach/Documents/... i can do this but if i send sumone my program
it wont load the pictures cuz there path wont be the same. Ive tried just Name.jpeg but it always says the files doesnt exist unless i put a
full path in, my teacher cant help me because she knows nothing about java. So i was wondering if anyone could tell me a way to locate a file
on your computer so your program can get it without it being in an exact path or what im doing wrong.
Thanks

[http://www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html]
Something to think about anyway. In general one avoid using hard-coded file paths (for the reasons you mentioned) and instead uses urls to load resources with class loaders.
This has the advantage of working portably and in jars as well.

Similar Messages

  • Failed to load image file-manager

    Hello everybody,
    I've recently install ArchLinux (0.6) on my machine. Then do a pacman -Sy and pacman -Su and fresh install xfree86, gnome and gnome-extra but when I run into gnome a window error appears:
    error
    Failed to load image file-manager
    Details: file not found
    I can't see mostly of the icons, like the foot of gnome in applications, the icon of file browser, the show desktop ..
    what can it be?
    well, thanks in advance.
    Ps: xscreensaver should be added as a dependency when pacman -S gnome
    Ps2: sorry my poor english

    Blaasvis wrote:i am aware, this was caused by the gtk2 update
    Yes, you're right.
    To solve (until a next release) I done:
    pacman -Rcd gtk2
    pacman -A /var/cache/pacman/pkg/gtk2-2.4.0-1.pkg.tar.gz
    And avoid to do pacman -Su ...
    Thanks and bye.

  • Error -11003:Menu-Fail loading Image file

    HI:
    addMenus XML File:
    <Application>
      <Menus>
        <action type="add">
          <Menu Checked="0" Enabled="1" FatherUID="43520" Image="title.bmp" Position="14" String="Menus" Type="2" UniqueID="Menus">
            <Menus>
              <action type="add">
                <Menu Checked="0" Enabled="1" FatherUID="Menus" Image="" Position="0" String="Menu_1" Type="1" UniqueID="Menu_1" />
              </action>
            </Menus>
          </Menu>
        </action>
      </Menus>
    </Application>
    when add the Image property , but continue error  Error -11003:Menu-Fail loading Image file.
    <h2>How to add images by using XML inside a B1DE project ?  </h2>
    Hope it helps
    Jimmy.l

    Hi
    在你的xml文件中,image 属性设置错误,应该填写你所加的image的绝对路径
    比如:
    <Application>
    <Menus>
    <action type="add">
    <Menu Checked="0" Enabled="0" FatherUID="43520" String="MyMenu1" Type="2" UniqueID="MyMenu1" Image="C:/MyPic.bmp">
    <Menus>
    <action type="add">
    <Menu Checked="1" Enabled="0" FatherUID="MyMenu1" String="MySub1" Type="1" UniqueID="MySub1" />
    </action>
    </Menus>
    </Menu>
    <Menu Checked="0" Enabled="1" FatherUID="43520" String="MyMenu2" Type="2" UniqueID="MyMenu2" >
    <Menus>
    <action type="add">
    <Menu Checked="0" Enabled="0" Position="0" FatherUID="MyMenu2" String="MySub21" Type="1" UniqueID="MySub21" />
    </action>
    </Menus>
    </Menu>
    </action>
    </Menus>
    </Application>

  • How to delete a jar file after loading image files from it

    Hi,
    How can I delete a jar file after some image files have been loaded? For example, say, I have "a.jar" which contains an image "a.gif" in the root directory of the c drive. I would like to get the image size and then delete the jar file. Here is the code snippet:
        URL url = new URL("jar:file:/C:\\a.jar!/a.gif");
        Icon icon = new ImageIcon(url);
        System.out.println("icon size ? " + icon.getIconHeight());
        File file = new File("c:\\a.jar");
        while(file.exists())
            file.delete();
            try
                Thread.sleep(100);
            catch (InterruptedException ignored)
        System.out.println("file deleted.");I get the image size correctly but just can not delete the jar file. Apparently the file handle is not released, but how to close it? Any hint will be appreciated.
    Justin Jan

    I am sure the URLConnection.defaultUseCaches is set before it is connected otherwise I should catch an IllegalStateException on conn.setUseCaches(false).
            try
                URL url = new URL("jar:file:/C:\\a.jar!/a.gif");           
             URLConnection conn = url.openConnection();
               conn.setDefaultUseCaches(false);
             conn.setUseCaches(false);
                Icon icon = new ImageIcon(url);
                System.out.println("icon size ? " + icon.getIconHeight());
                url.openConnection().getInputStream().close();
                System.gc();
             System.runFinalization();
                File file = new File("c:\\a.jar");
                while (file.exists())
                    file.delete();
                    try
                        Thread.sleep(10);
                    catch (InterruptedException ignored)
                System.out.println("file deleted.");
            catch (Throwable t)
                t.printStackTrace();

  • Error in pda load image file performanc​e in PDA

    hello
    i am using Windows CE with labview mobile module 8.6 in evaluation version. When trying to use "pda load imege file.vi" i get an error code 1, regardless of loading a .bmp, .gif or .jpg, of only 80kb (no diference in the color depth i use). I have tryed the same program in the windows mobile 5 emulator with the same error code. When i use "pda load bmp.vi" to load a .bmp, everything is OK. Some hints about this error?
    some hints about missing dll are provided here
    http://forums.ni.com/ni/board/message?board.id=170​&message.id=185995&query.id=129565#M185995 -> can that be my problem? but then, why same error in the emulator?
    Aditionally, if .gif or .jpg have to be "flatened" to pixmap for opeation inside my VI , is there any difference (in terms of speed and memory allocation) in loading .gif .jpg or .bmp? i have to operate with the raw pixmap data in "real time", and flatened .bmp images (320x220) do not load and update fast enough... any advice for that?

    Michiel
    acording to the info provided 
    LabVIEW 8.6 Mobile Module
    The
    LabVIEW 8.6 Mobile Module includes the necessary Microsoft tools. The
    Mobile Module installs ARM Pocket PC and Windows Mobile targets. You
    only need to download and install the following additional Microsoft
    tools (linked below) if you need x86 emulator targets:
    Microsoft eMbedded Visual C++ 4.0
    Microsoft eMbedded Visual C++ SP 4 or later
    SDK for Windows Mobile 2003-based Pocket PCs
    Note: If you are upgrading from version 8.0 or later of the PDA Module, you probably already have the additional tools. 
    Since
    i have  an ARM pocket PC, i understand from the above that  no extra
    software is needed. Anyhow, i will try to install the recomended tools.
    About the VI, well, basically not even the library examples work in my
    pocket PC, so, you may try those to see if they work on your devices. I
    am afraid that the pocket PC i got (it is actually a PNA and not a PDA)
    has a reduced version of WINDOWS CE 5.0 installed and that can be the
    reason for the error...
    regards 
    regards

  • Load image file into a LONG RAW column via SQL*Loader

    Does anyone know how to load a image file into a LONG RAW column via SQL*Loader?
    Thanks
    -Hsing-Hua-

    Are you trying to import the image on the client into Oracle lite, or from the server end into the main oracle database for download to the client?
    On our system images are loaded into the the oracle lite database (10g R1 at the moment) on the client (DELL X50 PDA's) into a BLOB (Not LONG RAW) column using Java (relatively standard functionality in Java) as this is what our application software is written in.
    From the server end, we do not at the moment load images as such, but we do load the application software into the database for deployment of new versions to the clients (the DMC/DMS updates we have found very unreliable), and the technique should be the same for images. Again the file is imported into a BLOB column.
    NOTE a column defined as BLOB on the main Oracle database appears as a LONG VARBINARY on the client Oracle lite database, but the synchronisation process handles the conversion with no problem.
    To import into a BLOB column on the server try the following
    1) you will need to create a DIRECTORY (CREATE DIRECTORY command) within the database, pointing at a directory on the database server (or accessible from it). This is needed for the file location.
    CREATE OR REPLACE DIRECTORY PDA_FILE_UPLOAD AS '/pdaapps/jar/'
    NOTE create directory needs to be run as SYSTEM
    2) define your table to hold the image and other data. Our tables is
    SQL> desc pda_applications
    Name Null? Type
    ID NOT NULL NUMBER(12)
    PDAAT_CODE NOT NULL VARCHAR2(10)
    VERSION NOT NULL NUMBER(5,2)
    PART_NO NOT NULL NUMBER(3)
    FILE_OBJECT BLOB
    DEPLOY_APPLICATION_YN NOT NULL VARCHAR2(1)
    3) copy the image (or in our case a .jar file) to the database server directory specified in step 1
    4) the actual import is done using a DBMB_LOB procedure
    PROCEDURE pr_load_file
    Module Name     :     pr_load_file
    Description     :     Main call. Create a new pda_applications record, and import the specified file into it
    Version History:
    Vers. Author Date Reason
    1.0 G Wilkinson 03/02/2006 Initial Version.
    (PA_VERSION IN NUMBER
    ,PA_FILENAME IN VARCHAR2
    ,PA_PDAAT_CODE IN VARCHAR2
    ,PA_PART_NO IN NUMBER DEFAULT 1
    ,PA_DEPLOY IN VARCHAR2 DEFAULT 'Y')
    IS
    l_FileLocator BFILE;
    l_blobLocator BLOB;
    l_seq NUMBER;
    l_location VARCHAR2(20);
    no_params EXCEPTION;
    call_fail EXCEPTION;
    BEGIN
    -- Throw error if required details not present
    IF pa_version IS NULL
    OR pa_filename IS NULL
    OR pa_pdaat_code IS NULL THEN
    RAISE no_params;
    END IF;
    -- Initialize the BLOB locator for writing. Note that we have
    -- to import a blob into a table as part of a SELECT FOR UPDATE. This locks the row,
    -- and is a requirement for LOADFROMFILE.
    SELECT pdaa_id_seq.nextval
    INTO l_seq
    FROM dual;
    -- First create the application record (file is imported by update, not insert
    INSERT INTO pda_applications
    (ID,PDAAT_CODE,VERSION,PART_NO,FILE_OBJECT,DEPLOY_APPLICATION_YN)
    VALUES (l_seq,pa_pdaat_code,pa_version,pa_part_no,EMPTY_BLOB(),pa_deploy);
    -- Lock record for update to import the file
    SELECT file_object INTO l_blobLocator
    FROM pda_applications
    WHERE id=l_seq
    FOR UPDATE;
    -- Initialize the BFILE locator for reading.
    l_FileLocator := BFILENAME('PDA_FILE_UPLOAD', pa_filename);
    DBMS_LOB.FILEOPEN(l_FileLocator, DBMS_LOB.FILE_READONLY);
    -- Load the entire file into the character LOB.
    -- This is necessary so that we have the data in
    -- character rather than RAW variables.
    DBMS_LOB.LOADFROMFILE(l_blobLocator, l_FileLocator
    ,DBMS_LOB.GETLENGTH(l_FileLocator)
    ,src_offset => 1);
    -- Clean up.
    DBMS_LOB.FILECLOSE(l_FileLocator);
    -- Create download records for each user associated with the application for sending to the PDA's
    -- to install the software
    IF pa_deploy = 'Y' then
    IF fn_deploy (pa_pdaa_id => l_seq
    ,pa_pdaat_code => pa_pdaat_code) != 'SUCCESS' THEN
    RAISE call_fail;
    END IF;
    END IF;
    EXCEPTION
    WHEN no_params THEN
    pkg_appm.pr_log_message( pa_mdl_name => g_module_name
    , pa_mdl_version => fn_get_body_version
    , pa_error_code => SQLCODE
    , pa_location => l_location
    , pa_text => 'Missing parameters'
    , pa_severity => 'E'
    WHEN OTHERS THEN
    DBMS_LOB.FILECLOSE(l_FileLocator);
    pkg_appm.pr_log_message( pa_mdl_name => g_module_name
    , pa_mdl_version => fn_get_body_version
    , pa_error_code => SQLCODE
    , pa_location => l_location
    , pa_text => SQLERRM
    , pa_severity => 'E'
    END pr_load_file;
    I hope this may be of some help

  • TextureLoader:  Error loading image file

    Hello,
    I am trying to load a .gif file to texture map a plane. Well I keep running into a problem loading the .gif file. It just does not load. I get a NullPointerException at the TextureLoader theLoader = new TextureLoader(fileName, observer); I have the .gif file in a folder named TextureImages which is in the same directory as the class that tries to load the file. I have loaded the same .gif file in a different simple test program. But in this program I am having no luck. If anyone has the answer. Please Help.
    Here is the class that tries to load the .gif file
    package roomPackages.shapes;
    //----Import statements
    import javax.media.j3d.Texture2D;
    import java.awt.Component;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import com.sun.j3d.utils.image.TextureLoader;
    public class CabnetFloorKSD extends Shape3D
    //----Member objects and varibles
    private double WIDTH; //Cabnet width scaled down by 12
    private Appearance theAppearance; //The cabnet appearance
    private PolygonAttributes poly_attributes; //Polygon attributes "normal vectors"
    private static Component observer;
    //----Constructor
    // ---------------------------------------------------------- CabnetFloorKSD
    // This constructor function builds the Shape3D by using the addGeometry
    // function to "glue" together all the QuadArrays. Which represent a
    // specfic face of the kitchen floor single door cabnet.
    public CabnetFloorKSD(double width, Canvas3D theCanvas)
    //----Varibles and objects
    this.WIDTH = width; //Getting the width value
    theAppearance = new Appearance(); //Cabnet appearance
    observer = theCanvas;
    loadTextureImage();
    //----Building the cabnet functions are here
    //----Setting the shapes appearance here
    }//end CabnetFloorKSD(double width)
    // --------------------------------------------------------- loadTexureImage
    // This is where the problem is
    public void loadTextureImage()
    //----Local varibles and objects
    String fileName = "TextureImages/OAK.GIF";
    //---- This line is where the NullPointerException happens
    TextureLoader theLoader = new TextureLoader(fileName, observer);
    /*ImageComponent2D theImage = theLoader.getImage();
    Texture2D theTexture = new Texture2D(Texture.BASE_LEVEL, Texture.RGB, 128, 128 );
    theTexture.setImage(0, theImage);
    theAppearance.setTexture(theTexture);
    }//end loadTextureImage()

    Hi,
    Instead of passing string argument to ImageLoader pass (URL,observer)
    ImageLoader(new URL("file:./img.gif",observer);
    Regards,
    shi

  • Error -11003 Menu falied loading image file - B1DE - AddMenu.xml

    Hi I am using B1DE to develop a add-on.
    I ran into error message as above when tried to add the "UI2.bmp" - an image file for the popup menu.
    Can someone advise on this ?
    <Application>
      <Menus>
        <action type="add">
          <Menu Checked="0" Enabled="1" FatherUID="43520" Image="ui2.bmp" Position="13" String="&amp;Transport System" Type="2" UniqueID="AFON_00">
            <Menus>

    Lai,
         While Calling main menu u also apply tha following code
    Dim menuitem As SAPbouiCOM.MenuItem
                menuitem = v_app.Menus.Item("FAST_Costing")
                menuitem.Image = Application.StartupPath & "\Costing.Jpg"
    Satisfy reward points,
    Regards,
    Anitha

  • Loading Image file

    hi All,
    i have created a jar file for my Application
    jar cvf Myjar.jar manifest.txt *.class *.PNG
    when i i opened , the appln will be opened but the image (PNG) is not displayed , but it is in jar file
    how to solve it
    please if you know
    thanks
    vinoth

    use this one in ur code where u fetching the image
    UIHelper.class.getResource("images/" + fileName);//UIHelper is the userdefined class.

  • PSE10 and PSE11 changing original date of image file on loading file to editor.

    There seem to be a problem with PSE10 and PSE11 on my computer when loading image files digitized on my film scanner. When loaded into the editor the image file immediate takes today’s date and time, and thus changes place on the timeline. However, sometimes the original image file date remains intact, for no obvious reason. I find this very frustrating.
    My setup is an HP computer running Windows7 Ultimate 64 bit, with  i7 processor and 12GB memory. My film scanner is a Minolta Dimage Elite II working with a Windows XP-based computer, and data are transferred using memory stick.
    Is there anybody out there able to advise me on what to do about the problem?
    It might be mentioned that I have made tests with a fixed set of image files on several computers running WindowsXP 32 bit, and several versions of PSE , including PSE10, without seeing this problem.

    If you have had a look at your other post,
    Why does PSE10 change my file date to today?
    you may be able to spot what can have triggered the updating of the catalog. There are too many date types in the exif, some of them are misleading. What is really interesting for a scan? For me (familiy history, genealogy) it's the supposed 'Date taken' or 'CreateDate' to display file chronogically. The file date in the OS is useful for backups.
    It's possible that the date digitized has some meaning for you.
    If you want to compare the different dates shown by John R Ellis in the Organizer database with those you see in an exif browser (or the properties in the editor, or the information panel in the organizer), you have to note that the 5 types of dates stored in the catalog database are;
    -pse:FileDate
    -Pse:FileDateOriginal
    -xmp:CreateDate
    -pse:TagDate
    -pse:LastOrganizerModifiedTime
    What's important to troubleshoot  your problems is to find what operation triggers the updating of the catalog from the files or vice versa.
    That can be: Update thumbnail, Write Metadata to files or...

  • Can load image from file using LabVIEW and display on IMAQ graph?

    I dont have IMAQ Vision for LabVIEW on my computer. Is it possible to load image file and display on an IMAQ graph?
    Thanks!

    Hey werwr,
    In response to: "I dont have IMAQ Vision for LabVIEW on my computer. Is it possible to load image file and display on an IMAQ graph?"
    As of right now, in order to read an image from file, you actually do need the IMAQ Vision software. The IMAQ driver without the Vision VI's will allow you to collect images from a framegrabber, and it will allow you to save those images to file. But the function that allows you to read an image from file does require the Vision VI's. Once you have the VI to read images from a file, you will be able to display the image on an IMAQ "Graph" or otherwise known as an Image Display.
    I hope this helps. Please let me know if you have any further questions.
    Thanks,
    DJ
    Applications Engineer
    National Instruments

  • Read Image File - Dr. Watson Error

    Greetings,
    Sorry for posting Developer4.5 problem here. I am reading an
    image (JPG) file from Forms Builtin Read_Image_File. Whenever it
    try to load image file to image item it gives Dr. Watson Error.
    I am working on Forms4.5.9.7.0 on Windows NT with service pack
    3.0. Thanks for any help.
    Regards
    Ajay Khandelwal
    null

    The problem was with the version. There was bug in the
    Forms4.5.9.7.0 version. I changed the JPEG to JFIF format and
    its running perfectly. The newer versions support the JPEG
    format also. Thanks for bearing me.
    Ajay Khandelwal
    ajay khandelwal (guest) wrote:
    : Greetings,
    : Sorry for posting Developer4.5 problem here. I am reading
    an
    : image (JPG) file from Forms Builtin Read_Image_File. Whenever
    it
    : try to load image file to image item it gives Dr. Watson Error.
    : I am working on Forms4.5.9.7.0 on Windows NT with service pack
    : 3.0. Thanks for any help.
    : Regards
    : Ajay Khandelwal
    null

  • Using Power Query to import image files for Power View

    I am trying to use Power Query to import image data from a SQL Azure database for use in Power View.  I've selected both the source image table and the ?images table in the workbook query.  The files seem to load as binary data in the Power
    Query editor but when loaded to the data model with Power Pivot, the field becomes "text" type rather than binary.  Does anyone know the procedure to use  PowerQuery to load image files into PowerPivot?

    Hi,
    We currently do not support loading binary data from Power Query into the Power Pivot data model. This is something we'd like to address soon. For now, you will need to use the Power Pivot import capabilities if you want to achieve this.
    Sorry about the inconvenience - we will try to enable this feature over the coming months.
    Faisal Mohamood | Program Manager | Data Platform Group - Microsoft

  • Referencing loaded images in APEX

    Hi all:
    Up until this point, I have used the same method of getting images to be recognized by an Apex
    installation. That specifically has been through loading images into a physical directory on the
    machine where APEX was installed. This was made available to me by the DBA that installed APEX.
    This is Application Express 2.2.0.00.32 running on AIX Unix.
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
    This arrangement worked. I was able to reference any image loaded to that directory using
    "/i/[image].gif". "/i/" was set as my pseudo directory by default on Apex.
    Over time, I developed an application that is now ready to deploy in like environments and I have
    never had a problem with viewing graphics.
    For the purposes of demoing to a specific customer, I was asked to deploy this to a different environment
    temporarily, I was given the option of loading my application to a Windows XP environment running
    Oracle XE and Application Express 2.1.0.00.39.
    Since there was no physical directory that I could locate for images, it seemed to me that my only
    option was to load my images using the wizard for loading image file components (which I understand
    means using XDB)...
    I was not been able to get this to work. I went back to my AIX Unix/Oracle 10g installation and attempted
    to do the same (load images as a file component and reference them). To my surprise it didn't work there
    either.
    These are the steps I took in attempting this:
    1.) Within my application definition, go to "Shared components"
    2.) Under the Files section, I click on "images"
    3.) Click on the button labeled "Create"
    4.) The page "Create Image" appears. I click on the "Browse" button and I pick the image from my local file system.
    5.) I leave the drop-down list as is (reading "No Application Associated")
    6.) I click on the "Upload" button.
    I then go back to my application under "Edit Attributes" and reference the file as /i/[file].gif
    I find that the images do not show up. On IE, all I get is the standard red "X" indicating that
    an image file failed to load.
    I can't help thinking that I'm missing an obvious step. Let me know if there's any other info I should
    provide.
    Thanks

    HI,
    To reference images loaded through shared components use:
    #WORKSPACE_IMAGES#filename.gif (when you set it to No Application Associated)
    or
    #APP_IMAGES#filename.gif (when you associate it with a specific application)
    Graham

  • Error:  BFILE not exists when i insert an image file(.jpg)

    Hi,
    i have created a directory
    called sampl_dir as '/home/oracle/files'
    i have an image file(.gif) and 3 pdf filesin the
    directory.
    i insert 4 rows in to the table using BFILE for all
    the 4 LOB.
    i get output in TOAD, where for all the pdf files, but when i select * from table.
    for all the pdf files output says 'EXISTS' but for the image(.gif) FILE, the
    output says 'NOEXIST'
    I tried putting all the files in different locations
    and tried giving different file owner, and group owner
    but whatever permissions i set or wherever i put the
    files, the output always says 'EXISTS' for pdf files
    but not for gif file.
    so i was thinking there is something got to do with
    the format of the image file, or is there someother
    way to select image from the table. i mean i thought
    "select * from table" may be does not work for images
    but it does work for text, pdf documents. am i right?
    how do i solve this?
    Thanks,
    Philip.

    Hi Kamal,
    this was the plsql code i used to load image file and read the length. and it did not work
    DBMS_LOB.LOADBLOBFROMFILE(v_dest_blob, v_source_locator1, DBMS_LOB.LOBMAXSIZE, v_dest_offset, v_source_offset);
    DBMS_OUTPUT.PUT_LINE('Size of BLOB post-load: '||(v_dest_offset -1));
    but now i modified the above as the following one shown below and it worked, can u tell what was the problem with the above code
    DBMS_LOB.LOADBLOBFROMFILE(v_dest_blob, v_source_locator1, DBMS_LOB.LOBMAXSIZE, v_dest_offset, v_source_offset);
    DBMS_OUTPUT.PUT_LINE('SIZE OF IMAGE FILE: ' ||DBMS_LOB.GETLENGTH(v_dest_blob));
    i did the select query as u told for selecting the length and now it works and i am able to see the output length as 27342.
    Okay Kamal, now is there a way that i can view a pdf file and image file after i select them from the table. i mean when i do a select query on the blob column, i only see result as "(HUGEBLOB)". BUT instead can i see whether what is the blob that is stored like whether it is a pdf or image and what is the name.
    how can i actually see the blob file names etc.
    Thanks,
    Philip.

Maybe you are looking for