Problems Loading Pictures with DrJava and the Media Computation Library

This morning, we got a support request for DrJava that mentioned path problems with the Media Computation library from Georgia Tech.

While some of the problems mentioned could not be reproduced or were simply due to not understanding Java syntax, there was one issue that might affect many users of the Media Computation library: Pictures (and problably other resources) aren’t found even though they should be. They fail to load:

String picFile = FileChooser.pickAFile();
> System.out.println(picFile)
/Users/shoshanaholtzblatt/Documents/CMU/Java/intro-prog-java/mediasources/caterpillar.jpg
> Picture.setMediaPath("/Users/shoshanaholtzblatt/Documents/CMU/Java/intro-prog-java/mediasources/");
The media directory is now /Users/shoshanaholtzblatt/Documents/CMU/Java/intro-prog-java/mediasources/
> Picture pictureObj = new Picture("caterpillar.jpg");
Couldn't load the file caterpillar.jpg

I have experimented a bit with the Media Computation library and found
that the first problem has to do with the working directory of the
Interactions Pane. Please make sure that it is the same as the directory
you pass to Picture.setMediaPath(). You can change the Interactions Pane’s
working directory by going to Edit -> Preferences, selecting the
“Interactions Pane” category and entering a path for “Interactions Working
Directory”.

Before I did that, I had the same problem as your student. Once I set the
working directory, I was able to load the picture:

Welcome to DrJava. Working directory is /home/mgricken/Desktop/mediaComp/mediasources
> String picFile = FileChooser.pickAFile();
> picFile
"/home/mgricken/Desktop/mediaComp/mediasources/caterpillar.jpg"
> Picture.setMediaPath("/home/mgricken/Desktop/mediaComp/mediasources")
The media directory is now /home/mgricken/Desktop/mediaComp/mediasources
> Picture pictureObj = new Picture("caterpillar.jpg");
>

Please note that we do not develop the Media Computation library and
therefore may not be in the best position to help you. You may want to
contact the authors at Georgia Tech using the resources on their website. But if there is something we can change in DrJava to make the Media Computation library easier to use, please let us know.

Share

About Mathias

Software development engineer. Principal developer of DrJava. Recent Ph.D. graduate from the Department of Computer Science at Rice University.
This entry was posted in DrJava. Bookmark the permalink.

Leave a Reply