使用JFileChooser的Git存储库错误消息

时间:2013-12-12 01:02:51

标签: java eclipse swing git jfilechooser

我正在使用Eclipse。当我使用JFileChooser时,消息fatal: Not a git repository (or any of the parent directories): .git一直出现在控制台中。每当我导航到新文件夹时,都会再次打印相同的消息。我还注意到,如果我导航到一个git存储库的文件夹,控制台将打印目录路径而不是错误消息。

以下是我使用的代码:

import javax.swing.JFileChooser;

public class JFileChooserTest
{
    public static void main (String[] args)
    {
        JFileChooser test = new JFileChooser ();
        test.showOpenDialog (null);
    }   
}

我尝试在Doctor Java中运行上面的代码,并且没有出现错误消息,所以我认为这个问题与Eclipse有关。

为什么会这样?有没有办法关掉这些消息?

1 个答案:

答案 0 :(得分:2)

我在Win7盒子上遇到了同样的问题(我在谷歌搜索时发现了你的问题)。就我而言,我的代码是:

Desktop.getDesktop().browse(new File("C:\\test.html").toURI());

我收到了完全相同的错误消息(错误输出,没有任何异常):fatal: Not a git repository (or any of the parent directories): .git

我正在使用JDK 1.7.0_51。

我注意到只有在使用Eclipse或批处理文件启动应用程序时才会出现此问题。使用.exe启动程序,代码按预期工作,没有错误消息。 使用“进程监视器”工具我注意到我的java.exe进程执行Windows注册表查找(肯定是为了让正确的应用程序打开我的文件)最终导致Git shell扩展DLL,然后我的进程启动命令“git rev-parse --show前缀”。我正在使用Git 1.7.11和http://msysgit.github.io的Windows shell扩展。卸载Git后,我不再收到此错误消息,但仍未打开请求的网页:(

绝对不是JFileChooser问题。但肯定是相对于Windows shell扩展,而JVM本机的东西正在播放文件......