So I've been trying to play around with Java 3D and, recently, I've been playing around with importing outside 3D models into a program. At this point, I can get the model into the program as an OBJ file, but for whatever reason, the program won't load the corresponding material file.

This is the code I wrote:

import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.loaders.objectfile.*;
import com.sun.j3d.loaders.Scene;
import java.awt.Color;
import javax.vecmath.*;
import javax.swing.*;
import javax.imageio.IIOException;

public class ModelLoadingTest {

    public static void main(String[] args) {
        SimpleUniverse universe = new SimpleUniverse();
        BranchGroup scene = new BranchGroup();
        ObjectFile loader = new ObjectFile(ObjectFile.RESIZE);
        Scene modelScene = null;
        Shape3D model = new Shape3D();
            modelScene = loader.load("Pterodactyl.OBJ");
            model = (Shape3D) modelScene.getSceneGroup().getChild(0);
            //JOptionPane.showMessageDialog(null, model.getAppearance().getMaterial());
        catch(Exception e){
            JOptionPane.showMessageDialog(null, e.toString());
        DirectionalLight lighting = new DirectionalLight(new Color3f(Color.WHITE), new Vector3f(0f, 0f, -1f));
        lighting.setInfluencingBounds(new BoundingSphere(new Point3d(0.0, 0.0, 1.0), 100));
This is the beginning of the .obj file:

# 3ds Max Wavefront OBJ Exporter

mtllib Pterodactyl.mtl

# object Pterodactyl

v  121.2250 19.0041 66.8833
v  116.1940 12.5999 63.5611
v  135.5396 13.8324 64.7891
v  137.5667 21.8641 68.2204
v  121.5318 24.7219 64.6238
v  170.6878 5.0353 69.7959
And this is the corrosponding .mtl file:

# 3ds Max Wavefront OBJ Exporter

newmtl pterodactyl_MAT
	Ns 10.0000
	Ni 1.5000
	d 1.0000
	Tr 0.0000
	Tf 1.0000 1.0000 1.0000 
	illum 2
	Ka 0.5880 0.5880 0.5880
	Kd 0.5880 0.5880 0.5880
	Ks 0.0000 0.0000 0.0000
	Ke 0.0000 0.0000 0.0000
	map_Ka Pterodactyl_D.tga
	map_Kd Pterodactyl_D.tga
Now, the code runs fine when the mtllib call in the .obj file is removed (save for the fact that the pterodactyl is white and has a material generated by default by the Java 3D library), but when the mtllib call is present and uncommented in the .obj file, the following error occurs when I run the program:

com.sun.j3d.utils.image.ImageException: javax.imageio.IIOException: Can't read input file!
Now, I'm not sure if I'm correct, but for this exception to occur in the first place, the program has to acknowledge that the .mtl file exists which begs the question of why it can't read it. Is it because the .mtl file is formatted wrong? Is it because the call in the .obj file is wrong or located in the wrong part of the file, or is it something to do with my coding?

Sidenote: Before anyone suggests it as a fix, Pterodactyl.obj and Pterodactyl.mtl ARE in the same folder.