Java 找不到资源文件

Java 找不到资源文件,java,intellij-idea,Java,Intellij Idea,我是java新手,但我能找到足够的方法来做一些简单的编程 我遇到了这个问题,我想我应该试试(使用Intellij14、Windows8.1、GeForce图形卡) 在添加所有javax库等后,程序会编译,但随后会出现此错误 java.io.FileNotFoundException: heli.obj (The system cannot find the file specified) Error could not load sound file: javax.media.j3d.Soun

我是java新手,但我能找到足够的方法来做一些简单的编程

我遇到了这个问题,我想我应该试试(使用Intellij14、Windows8.1、GeForce图形卡)

在添加所有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,但出现了一个“错误”

有人能帮忙吗

谢谢
Steve

我真的不知道问题出在哪里,但我可以推测,您获得的项目是在假设可执行文件将运行在特定目录下,特别是heli.obj所在的目录下构建的

他们可能在某个地方的自述文件中解释了这一点,而你可能已经错过了


因此,您需要离开loadGeometryGroup(“heli.obj”,app)按原样,您需要进入IntelliJ IDEA的
运行
菜单,
编辑配置…
,在左侧的树中找到应用程序的配置,并在右侧指定
工作目录。

C-:=很高兴能提供帮助。您可能想要“接受”我的答案。(如果你有足够的声誉,你可能也会想提高投票率。)我接受了你的回答,但由于这是我的第一个话题,我无法提高投票率,但谢谢你的快速回复。