当我在 MAC OS X 上的 Eclipse Web 项目中运行此代码时
File file1 = new File("myfile.txt");
if( !file1.exists() ) file1.createNewFile();
System.out.println( file1.getAbsolutePath() );
它说
/Users/Richard/Desktop/eclipse/Eclipse.app/Contents/MacOS/myfile.txt
在我的 WINDOWS 7 计算机上,它显示
C:\Users\Richard\Documents\workspace\myproject\src\com\example\myclass\myfile.txt
如何让我的 Eclipse 在我的 MAC OS X 上运行,以像在我的 WINDOWS 7 上一样在我的 Documents 文件夹中输出文件,而不是进入 Eclipse.app APP BUNDLE 并放入文件夹 Contents/MacOS 中?
最佳答案
您可以在 Run
-> Run Configurations...
和 Arguments
选项卡下更改任何给定启动配置的工作目录。
奇怪的是,您的默认值似乎位于 Eclipse.app 包中 - 通常,它是 ${workspace_loc:
项目名称
}
.
不幸的是,看来你还是can't set the default working directory适用于所有新的运行配置。
关于java - MAC 上的 Eclipse,将当前目录设置为 Documents 文件夹而不是 APP BUNDLE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8641472/