Where to put a jpg using BlueJ

Hi everybody, since this year, I'm using BlueJ and processing to teach my students the java basics. I use BlueJ because later that year they have to use it for other projects. I put the processing "core.jar" in a folder wich is named "+libs" in my BlueJ project folder - no problem. But where do I have to put an image like "bild1.jpg" so it is found by processing. I tried to put it inside the BlueJ-project folder, inside the +libs-folder. I tried using "bild1.jpg", "./bild1.jpg", ".\bild1.jpg" . Everytime I got a Null pointer exception when using "image(img,0,0)". Thanks in advance for every hint, Ingo

Answers

  • Try using the sketchPath () method to find the location to store the images.

  • edited December 2017

    Also check out the String returned by dataPath(): L-)

    void settings() {
      println(dataPath("") + '/');
    }
    

    That folder path is the ideal place to put in any loadable resources. :)>-

  • Thank you very much for both suggestions, but neither one worked.

    I tried:

    println(dataPath("") + '/');

    and got

    /Users/MyName/Desktop/PicManipulation/data/

    Using sketchPath() I got

    /Users/MyName/Desktop/PicManipulation//

    By the way, "PicManipulation" is the name of the BlueJ-Project and I'm worked on a mac using 10.10.5, but my students use Win7 or Win10.

    Because there was not such a folder, I created one and put the file inside of it. It didn't work.

    So this is, what I have now:

    public void settings() { size(320, 240); println(dataPath("") + '/'); println(sketchPath("") + '/'); img = loadImage("pic1.jpg"); }

    And this is my file structure: Bildschirmfoto 2017-12-10 um 15.10.41

    Any suggestions?

    Thanks in advance.``````

  • I guess an already compiled Processing Java program is gonna have its sketchPath field pointing to the folder where its ".jar" file is being run from. :-B

  • I tried that and put the jpg-file inside the +libs-folder. It didn't work. Sorry.

  • I've meant the sketch's ".jar", not Processing's library ".jar". :-\"

  • Well, the sketchpath is "/Users/MyName/Desktop/PicManipulation//" . So I tried putting it in the projectfolder "PicManipulation", but the pic wasn't found. How do I have to understand the "//" at the end of the sketchpath? And additional folder named "sketch" didn't work either.

Sign In or Register to comment.