我是新來的java,但可以找到我的方式足夠做一些簡單的編程。資源文件未找到
我碰到這個,我想我會嘗試(使用的IntelliJ 14,Windows 8.1中,GeForce圖形卡)
http://www.java2s.com/Code/Java/3D/Thisexamplecreatesa3DflyoverofthecityofBoston.htm
將所有等方面的程序編譯使用javax庫後,但隨後下降在這種錯誤
java.io.FileNotFoundException: heli.obj (The system cannot find the file specified)
Error could not load sound file: javax.media.j3d.SoundException: MediaContainer: setURL - bad URL
這似乎是它加載文件的行
protected Group createGeometryGroup(Appearance app, Vector3d position, Vector3d scale, String szTextureFile, String szSoundFile)
{
TransformGroup tg = new TransformGroup();
// we need to flip the helicopter model
// 90 degrees about the X axis
Transform3D t3d = new Transform3D();
t3d.rotX(Math.toRadians(-90));
tg.setTransform(t3d);
try
{
/////////////////////////////////////////////////////////
tg.addChild(loadGeometryGroup("heli.obj", app));
/////////////////////////////////////////////////////////
// create an Alpha object for the Interpolator
Alpha alpha = new Alpha(-1,
Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE,
(long) Utils.getRandomNumber(0, 500),
(long)Utils.getRandomNumber(0, 500),
(long)Utils.getRandomNumber(20000, 5000),
4000,
100,
(long) Utils.getRandomNumber(20000, 5000),
5000,
50);
attachSplinePathInterpolator(alpha,
new Transform3D(),
new URL(((Java3dApplet) m_Component).getWorkingDirectory(), "d:\\flyover\\heli_spline.xls"));
}
catch(Exception e)
{
System.err.println(e.toString());
}
return tg;
}
該文件和其他一些資源位於我的src目錄中,並被複制到out目錄。那麼,爲什麼程序不能找到它們,我應該在哪裏放置它們以便找到它們?
我也使用URI試圖 「文件:/// d:/Flyover/heli.obj」,卻得到了一個「MalformedURL錯誤
誰能幫助
感謝 史蒂夫
?
你是多麼好的人!現在解決了問題,謝謝。 – user3466354 2015-02-08 09:41:02
C - :=很高興能有幫助。你可能想'接受'我的答案。 (如果你有足夠的聲望,你可能也想upvote它。) – 2015-02-08 09:45:07
我接受你的答案,但因爲這是我的第一個話題,我不能upvote,但感謝您的快速答覆。 – user3466354 2015-02-08 09:53:45