找不到资源文件
Resource Files not found
我是 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 "file:///d:/Flyover/heli.obj",但收到“MalformedURL 错误。
有人能帮忙吗?
谢谢
史蒂夫
我真的不知道问题是什么,但我可以推测您获得的项目是在假设可执行文件将 运行 在特定目录中构建的,具体来说,heli.obj 活着。
他们可能在某处的自述文件中对此进行了解释,您可能错过了。
因此,您需要保持 loadGeometryGroup( "heli.obj", app )
不变,您需要转到 IntelliJ IDEA 的 Run
菜单,Edit Configurations...
,在树上找到您的应用程序的配置左侧,并在右侧指定 Working Directory
。
我是 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 "file:///d:/Flyover/heli.obj",但收到“MalformedURL 错误。
有人能帮忙吗?
谢谢 史蒂夫
我真的不知道问题是什么,但我可以推测您获得的项目是在假设可执行文件将 运行 在特定目录中构建的,具体来说,heli.obj 活着。
他们可能在某处的自述文件中对此进行了解释,您可能错过了。
因此,您需要保持 loadGeometryGroup( "heli.obj", app )
不变,您需要转到 IntelliJ IDEA 的 Run
菜单,Edit Configurations...
,在树上找到您的应用程序的配置左侧,并在右侧指定 Working Directory
。