CreateProcess error=206, The filename or extension is too long
Asked Answered
W

4

12

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

Warwick answered 13/1, 2012 at 12:57 Comment(3)
How are you calling findbug? directly running findbug or using findbug task?Armillia
using findbug task. the problem persist...Warwick
Possible duplicate of CreateProcess error=206, The filename or extension is too long when running main() method, Createprocess error=206; the filename or extension is too long and friends.Flagg
M
8

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>
Mutual answered 9/2, 2012 at 17:6 Comment(1)
I had the same problem but with <jacoco:coverage> and <junit>. There was a <classpath> with a <dirset> with many, many classes. I made a JAR with <jar destfile="${test.dist}/test-classes.jar"... and changed the <classpath> to <pathelement location="${test.dist}/test-classes.jar"/>. Then it worked!Missile
E
1

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

Ellerey answered 17/7, 2015 at 4:51 Comment(0)
L
1

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.

Likker answered 11/10, 2021 at 14:55 Comment(1)
This answer was really helpful - it gave me useable Ant commands to deal with the problem.Pearman
E
0

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"

Emerald answered 21/10, 2020 at 12:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.