2

As a JAVA beginner, I tried using GRAL via a tutorial. I came about the following error:

java.lang.RuntimeException: java.io.IOException: Property file not found: drawablewriters.properties

This runtime error came from the following lines of unaltered GRAL source code:

public final class DrawableWriterFactory extends AbstractIOFactory<DrawableWriter> {
 /** Singleton instance. */
 private static DrawableWriterFactory instance;

 /**
  * Constructor that initializes the factory.
  * @throws IOException if the properties file could not be found.
  */
 private DrawableWriterFactory() throws IOException {
  super("drawablewriters.properties"); //$NON-NLS-1$
 }

 /**
  * Returns an instance of this DrawableWriterFactory.
  * @return Instance.
  */
 public static DrawableWriterFactory getInstance() {
  if (instance == null) {
   try {
    instance = new DrawableWriterFactory();
   } catch (IOException e) {
    throw new RuntimeException(e);
   }
  }
  return instance;
}

The class above is reference in another class which is referenced the code that was initially run.

After reading about the keyword super, it seems super would never have a .properties file as an argument when used in a constructor. How does it use a .properties file in this case?

I noticed in the following question that a new InputStream is typically used to extract the contents of a .properties file. Is this somehow done with super?

Also, I simply tried placing drawablewriters.properties in the same directory as the source code above. This didn't work.

Community
  • 1
  • 1
brb
  • 21
  • 1

1 Answers1

0

The syntax super("drawablewriters.properties"); is merely an invocation of the constructor of this class' superclass. It can have whatever arguments are taken by one of the superclass' constructors. In this case it is invoking a constructor of AbstractIOFactory<DrawableWriter>.

The problem in your case is that the file drawablewriters.properties is not where the superclass constructor can find it. You should look at the documentation for AbstractIOFactory to learn how it resolves properties file names.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190