【发布时间】:2015-05-30 18:55:01
【问题描述】:
我已经开发了一个在 Windows 操作系统下在 Eclipse 上正确运行的 Java 项目。然后我想切换到 Ubuntu。我刚刚从 Windows 中获取了完整的工作区文件夹(包括运行所需的所有资源文件)并将其导入到 Ubuntu 的 Eclipse 中。
最令人惊讶的是,我得到了以下异常:
[ Test ] ERROR: unable to create myClass object.
Check your implementation requirements!
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at Test.main(Test.java:183)
Caused by: java.io.FileNotFoundException: raw\file1.txt (No such file or directory)
...
但是这样的目录和这样的文件确实存在于当前路径中。
为什么会发生这种情况?
【问题讨论】:
-
虽然 Windows 可以接受反斜杠作为路径分隔符,但 Unix 不接受。使用正斜杠。
标签: java linux windows filenotfoundexception