Welcome! Log In Create A New Profile

Advanced

FileNotFoundException in STLObject.addSTL

Posted by autophile 
FileNotFoundException in STLObject.addSTL
January 19, 2010 04:58PM
Hi all,

I have a binary STL file that I have hand-verified. It's very easy to verify, because it's just a box 1 inch by 2 inches by 3 inches.

However, this program results in a File Not Found exception when the STLLoader tries to load the file. Here's my test program:

import java.io.*;
import org.reprap.gui.STLObject;

public class Main
{
    public static void main(String[] args)
            throws Exception
    {
        File file = new File(args[0]);
   
        System.out.println("File " + file.getAbsolutePath() +
                " " + (file.exists() ? "exists" : "does not exist"));
        STLObject object = new STLObject();
        object.addSTL(file.getAbsolutePath(),
                null, null, null);
    }
}

Output:

File /Users/me/Desktop/box.stl exists
loadSingelSTL(): Exception loading STL file from: /Users/me/Desktop/box.stl
java.io.FileNotFoundException
        at org.j3d.renderer.java3d.loaders.STLLoader.load(STLLoader.java:82)
        at org.reprap.gui.STLObject.loadSingleSTL(STLObject.java:203)
        at org.reprap.gui.STLObject.addSTL(STLObject.java:178)
        at Main.main(Main.java:119)


I know the file exists, because Java says it does. I tried reading it (not shown in the code), and it reads fine. Nevertheless, J3D's STLLoader claims the file doesn't exist. I am using j3d-org-java3d-all.jar that I got from the RepRap SCM repository yesterday.

Worse, when I tried to look for the source code to org.j3d.renderer.java3d.loaders.STLLoader, I get led to code.j3d.org which doesn't even resolve.

So, two questions: (1) Why is STLLoader throwing a file not found exception? (2) Where is the source code to the org.j3d package?

My system:

MacOS 10.6.2
Macbook Pro / Intel Core2Duo
Java 5 (also 6 - fails on both)

Thanks,

--Rob
Re: FileNotFoundException in STLObject.addSTL
January 19, 2010 08:22PM
Oh. The String location parameter of STLObject.addSTL() takes a string containing a URI. Obviously.

Changing file.getAbsolutePath() to file.getURI().toString() solved the problem.
Sorry, only registered users may post in this forum.

Click here to login