2 Replies Latest reply: Jan 3, 2013 9:15 PM by aidreamer RSS


      Im trying to use an absolute path for image, cuz i want to choose an image from another hard drive: I use this on imageview and didnt work:

      ima= new ImageView(new Image(getClass().getResource("C:/Users/Alexandra/Documents/Scan.jpg").toString()));

      This results on an null string

      Edited by: anersantana on 03-ene-2013 14:29
        • 1. Re: imageview
          Haven't compiled it, but I'm guessing something like this:
          ima = new ImageView(new Image("file:/C:/Users/Alexandra/Documents/Scan.jpg"));
          • 2. Re: imageview
            For future reference, I think you are misunderstanding what getResource() is for. Class.getResource() is for getting the URL of an item saved to a package inside a jar file. So for instance, if you saved an image named "MyImage.png" inside a package named myprogram.main, the code might look like
            String packageURL = Main.class.getResource("/myprogram/main/MyImage.png").toString();
            Which would give you a url something like jar:file:/some_file_path/MyJarFile.jar!/myprogram/main/MyImage.png