CreateProcess error=206,文件名或扩展名太长

发布于 2024-12-26 13:00:29 字数 312 浏览 2 评论 0原文

我尝试通过 Ant调用Findbugs,但收到此错误:

Cannot run program "C:\Program Files (x86)\Java\jre6\bin\javaw.exe" (in 
directory "H:\Users\MyName\workspace\MyProject"): 
CreateProcess error=206, The filename or extension is too long

我该如何修复此问题? oO

I'm trying to call Findbugs via Ant, but receiving this error:

Cannot run program "C:\Program Files (x86)\Java\jre6\bin\javaw.exe" (in 
directory "H:\Users\MyName\workspace\MyProject"): 
CreateProcess error=206, The filename or extension is too long

How can I fix this? o.O

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

鸢与 2025-01-02 13:00:29

我也有同样的问题。

<fileset dir="${basedir}/build">
  <include name="**/*.class"/>
</fileset>

在 findbugs 目标内部使用了它,似乎有太多的 .class 文件要传递给 findbug (?通过命令行?),因为当我使用

<fileset dir="${basedir}/build/com/domain/package">
  <include name="**/*.class"/>
</fileset>

类数量较少的文件时,错误就消失了。

因此,我通过制作一个 jar 文件并将其提供给 findbugs 目标来解决这个问题

<findbugs home="${findbugs.home}">
  ...
  <class location="${basedir}/targets/classes-to-analyze.jar"/>
</findbugs>

I had the same problem.
I used

<fileset dir="${basedir}/build">
  <include name="**/*.class"/>
</fileset>

inside findbugs target and it seems that there is too much .class files to be passed to findbug (?via command line?) because when I used

<fileset dir="${basedir}/build/com/domain/package">
  <include name="**/*.class"/>
</fileset>

that had low number of classes, the error was gone.

So, I solved the problem by making one jar file and feeding it to findbugs target with

<findbugs home="${findbugs.home}">
  ...
  <class location="${basedir}/targets/classes-to-analyze.jar"/>
</findbugs>
放血 2025-01-02 13:00:29

我认为当 java 尝试编译类时,有效文件路径之一非常长。

一个值得尝试的方法是将代码库放在 C:\MyProject 等目录中,而不是 C:\Users\MyName\workspace\MyProject 之类的目录中

I think one of the effective file paths are really long when java tries to compile clases.

One worth try is to put codebase in a directory such as C:\MyProject instead of something like C:\Users\MyName\workspace\MyProject

伪心 2025-01-02 13:00:29

要解决此问题,您需要生成一个清单类路径和一个路径 jar。

首先生成你的类路径。

<path id="javac.path">
    <fileset dir="lib/" includes="**/*.jar"/>
</path>

Next 生成您的 Manifestclasspath

<target name="generate-manifest-classpath">
    <manifestclasspath property="manifest.classpath" jarfile="pathing.jar">
        <classpath refid="javac.path"/>
    </manifestclasspath>      
    <jar destfile="pathing.jar" basedir="${the location of your build classes}">
        <manifest>            
            <attribute name="Class-Path" value="${manifest.classpath}"/>
        </manifest>
    </jar>
    <path id="javac.classpath">
        <pathelement path="pathing.jar"/>          
    </path>
</target>

Next 实现您的 Manifestclasspath

<javac srcdir="${foo.dir}" destdir="${bar.dir}"
        <classpath refid="javac.classpath"/>
</javac>

如果正确实现,这将解决 206 错误消息。

To solve this issue you need to generate a manifestclasspath and a pathing jar.

First Generate your classpath.

<path id="javac.path">
    <fileset dir="lib/" includes="**/*.jar"/>
</path>

Next Generate your manifestclasspath

<target name="generate-manifest-classpath">
    <manifestclasspath property="manifest.classpath" jarfile="pathing.jar">
        <classpath refid="javac.path"/>
    </manifestclasspath>      
    <jar destfile="pathing.jar" basedir="${the location of your build classes}">
        <manifest>            
            <attribute name="Class-Path" value="${manifest.classpath}"/>
        </manifest>
    </jar>
    <path id="javac.classpath">
        <pathelement path="pathing.jar"/>          
    </path>
</target>

Next Implement your Manifestclasspath

<javac srcdir="${foo.dir}" destdir="${bar.dir}"
        <classpath refid="javac.classpath"/>
</javac>

This will solve the 206 error message if implemented correctly.

难忘№最初的完美 2025-01-02 13:00:29

仅启动调试模式时,我在 IntelliJ 上遇到了相同的错误。要解决的是我已经更改:

运行> 编辑配置 > “配置”选项卡 > 将命令行缩短

“JAR-manifest”

I had the same error on IntelliJ while starting debug mode only. To fix is I've changed:

Run > Edit Configurations > "Configuration" tab > Shorten command line

to "JAR-manifest"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文