找不到资源文件

时间:2015-02-08 08:29:43

标签: java intellij-idea

我是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" ;,但得到了#34; MalformedURL错误。

有人可以帮忙吗?

感谢 史蒂夫

1 个答案:

答案 0 :(得分:0)

我真的不知道问题是什么,但我可以推测你获得的项目是在假设可执行文件将在特定目录中运行的情况下构建的,特别是heli.obj所在的目录。

他们可能会在某个自述文件中解释这个问题,你可能已经错过了。

因此,您需要按原样离开loadGeometryGroup( "heli.obj", app ),然后您需要转到IntelliJ IDEA的Run菜单Edit Configurations...,找到您的应用程序的配置左侧的树,并指定右侧的Working Directory

相关问题