score:58

Accepted answer

there is no simple (as in a couple of clicks or a simple command) solution to this issue.

quoting from some answers in this bug report in eclipse.org, these are the work-arounds. pick the one that's the least painful to you:

  • reduce the classpath
  • use directories instead of jar files
  • use a packed jar files which contains all other jars, use the classpath variable inside the manifest file to point to the other jars
  • use a special class loader which reads the classpath from a config file
  • try to use one of the attached patches in the bug report document
  • use an own wrapper e.g. ant

update: after july 2014, there is a better way (thanks to @brad-mace's answer below:

if you have created your own build file instead of using project -> generate javadocs, then you can add useexternalfile="yes" to the javadoc task, which is designed specifically to solve this problem.

score:-2

this is because of your long project directory name, which gives you a very long classpath altogether. either you need to reduce jars added at classpath (make sure removing unnecessary jars only) or the best way is to reduce the project directory and import the project again. this will reduce the classpath. it worked for me.

score:-1

valid answer from this thread was the right answer for my special case. specify the orm folder path for datanucleus certainly reduce the java path compile.

https://stackoverflow.com/a/1219427/1469481

score:-1

i got the error below when i run 'ant deploy'

cannot run program "c:\java\jdk1.8.0_45\bin\java.exe": createprocess error=206, the filename or extension is too long

fixed it by run 'ant clean' before it.

score:-1

i got the same error in android studio. i was able to resolve it by running build->clean project in the ide.

score:-1

i've had the same problem,but i was using netbeans instead.
i've found a solution so i'm sharing here because i haven't found this anywhere,so if you have this problem on netbeans,try this:
(names might be off since my netbeans is in portuguese) right click project > properties > build > compiling > uncheck run compilation on external vm.

score:0

it happens due to datanucleus sometimes overwrite the arguments with many paths.

you have to overwrite them with this:

-enhancername asm -api jdo -pu mediatogo

hope help you!

score:0

i got the same error. tried solutions like cleaning, rebuild, invalidatecache, retart etc but nothing works.

i just have created a new folder with short name and copied all the files(app folder, gradle files etc) in new folder. opened application in android studio and its working fine.

score:0

to fix this below error, i did enough research, not got any great solution, i prepared this script and it is working fine, thought to share to the public and make use of it and save there time.

createprocess error=206, the filename or extension is too long

if you are using the gradle build tool, and the executable file is placed in build/libs directory of your application. run.sh -> create this file in the root directory of your project, and copy below script in it, then go to git bash and type run.sh then enter. hope this helps!

#!/bin/bash
dir_name=`pwd`
if [ $# == 1 ] && [ $1 == "debug" ]
then
    port=$random
    quit=0
    echo "finding free port for debugging"
    while [ "$quit" -ne 1 ]; do
        netstat -anp | grep $port >> /dev/null
        if [ $? -gt 0 ]; then
            quit=1
        else
            port=`expr $port + 1`
        fi
    done
    echo "starting in debug mode on "$port
    gradle clean bootjar
    jar_name="build/libs/"`ls -l ./build/libs/|grep jar|grep -v grep|awk '{print $nf}'`
    #java -jar -xdebug -xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$port $jar_name 
elif [ $# == 1 ] && [ $1 == 'help' ]
then
    echo "please use this commands"
    echo "------------------------"
    echo "start in debug mode: sh run.sh debug"
        echo "start in run mode: sh run.sh" 
    echo "------------------------"
else
    gradle clean bootjar
    word_count=`ls -l ./build/libs/|grep jar|grep -v grep|wc -w`
    jar_name=`ls -l ./build/libs/|grep jar|grep -v grep|awk '{print $nf}'`  
    jar_path=build/libs/$jar_name
    echo $jar_name
    #java -jar $jar_path
fi

hope this helps!!

score:0

for me it was wrong jdk path. please make sure you have right path to the jdk file

file -> project structure

enter image description here

score:0

if you are using android studio try invalidate caches/ restart.. option present in file menu

score:0

i used com.virgo47.classpathjar plugin to fix this issue https://plugins.gradle.org/plugin/com.virgo47.classpathjar

score:0

you can use below commands:

mklink /j c:\repo c:\<long path to your maven repository> 


mvn -dmaven.repo.local=c:\repo any mvn command

score:1

i have got same error, while invoking maven.

the root cause for my problem was the classpath was very huge. updating the classpath fixed the problem.

there are multiple ways to update the large classpath as mentioned in this: how to set a long java classpath in windows?

  1. use wildcards
  2. argument file
  3. pathing jar

since i am using intellij, they provide the option to use argument file that i used.

score:1

try this:

java -jar -dserver.port=8080 build/libs/app_name_here.jar

score:1

to solve it:

if you are using eclipse:

move .m2 repository to

c:\ go to eclipse > windows/preferences/maven/user settings -> create your own setting.xml with its content:

<settings>
  <localrepository>c:/.m2/repository</localrepository>
</settings>

if you are using intellij: go to intellij > clicking the right mouse button on "pom.xml" > maven > create "settings.xml"

with its content:

<settings>
      xmlns="yourcontent"
      xmlns:xsi="yourcontent"
      xsi:schemalocation="yourcontent.xsd">
  <localrepository>c:/.m2/repository</localrepository>
</settings>

score:1

in my case the error was showing because system java version was different from intellijj/eclipse java version. system and user had diff java versions. if you compile your code using one version and tried to run using a different version, it will error out. user java version is 1.8

#the system java version is 1.7.131
$ java -version
java version "1.7.0_131"

long story short, make sure your code is compiled and ran by the same java version.

score:1

i am using legacy version of gradle plugins and this plugin solved the issue for me.

usage (check source for more details):

build script snippet for plugins dsl for gradle 2.1 and later

plugins {
  id "com.github.manifestclasspath" version "0.1.0-release"
}

build script snippet for use in older gradle versions or where dynamic configuration is required

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "gradle.plugin.com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-release"
  }
}

apply plugin: "com.github.manifestclasspath"

score:1

in a windows machine, there is a limitation of the jar file name/path length in the command-line, due to which you see the below error message, i tried searching a lot, even i tried applying the above solution, some reason, it didn't work, i found the working snippet for gradle (gradle-4.10.2-all.zip)

error:

createprocess error=206, the filename or extension is too long

use this below gradle.build code snippet to fix the above problem in intellij or sts, or eclipse anything.

gradle code fix:

apply plugin: 'application'

task pathingjar(type: jar) {
    dependson configurations.runtime
    appendix = 'pathing'

    dofirst {
        manifest {
            attributes "class-path": configurations.runtimeclasspath.files.collect { it.getname() }.join(' ')
        }
    }
}

task copytolib(type: copy) {
    into "$builddir/libs"
    from configurations.runtime
}

bootrun {
    systemproperties = system.properties
    //this below line is for if you have different profiles prod, dev etc...
    //systemproperty 'spring.profiles.active', 'dev'
    jvmargs('-djava.util.logging.config.file=none')
    mainclassname = "com.xxxx.main"
    dependson pathingjar
    dependson copytolib
    dofirst {
        classpath = files("$builddir/classes/java/main", "$builddir/resources/main", pathingjar.archivepath)
    }
}

score:1

if you are using vscode:

  1. create launch.json file insde .vscode/

  2. add

    {"configurations": [{ "type": "java","shortencommandline ": "auto",}]}
    

if you are using intellij :

  1. open .idea/workspace.xml

  2. inside <component name="propertiescomponent"> add <property name="dynamic.classpath" value="true"/>

score:2

try adding this in build.gradle (gradle version 4.10.x) file and check it out com.xxx.mainclass this is the class where your main method resides:

plugins {
  id "ua.eshepelyuk.manifestclasspath" version "1.0.0"
}
apply plugin: 'application'
application {
    mainclassname = "com.xxx.mainclass"
}

the above change must resolve the issue, there is another way using script run.sh below could fix this issue, but it will be more of command-line fix, not in intellij to launch gradle bootrun.

score:3

in bug report bug 327193 it is considered fixed, but it happen to me recently with eclipse kepler 4.3.2.

please download patch for eclipse juno or newer:

https://bugs.eclipse.org/bugs/attachment.cgi?id=216593

  1. after download back up existing eclipse/plugins/org.eclipse.jdt.launching_3.*.jar
  2. copy and paste classes in the patch to org.eclipse.jdt.launching jar (replace existing files).
  3. restart eclipse.

score:3

add below to your gradle file:

plugins {
`id "com.github.manifestclasspath" version "0.1.0-release"       
}

see https://plugins.gradle.org/plugin/com.github.manifestclasspath

score:3

how many people sad above, there are a lot of plugins to gradle execute a by pass in this problem like:

plugins {
  id "ua.eshepelyuk.manifestclasspath" version "1.0.0"
}

or

plugins {
  id "com.github.manifestclasspath" version "0.1.0-release"
}

but the better solution that i found was kill the jvm process and everything is done.

score:6

try updating your eclipse version, the issue was closed recently (2013-03-12). check the bug report https://bugs.eclipse.org/bugs/show_bug.cgi?id=327193

score:6

question is old, but still valid. i come across this situation often whenever a new member joins my team or a new code segment is added to existing code. simple workaround we follow is to "reduce the classpath" by moving up the directories.

as question mentioned, this is not specific to eclipse. i came across this issue in intellij idea 14 and 2018 as well.

after a long research, i found the solution is to set the

fork = false

in javc of ant build file.

<javac destdir="${build.dir}" fork="false" debug="on">
    <classpath .../>
    <src ... />
    <patternset ... />
</javac>

this is how my ant build javac looks now. to learn about more on fork, please refer ant documentation.

score:7

this is not specifically for eclipse, but the way i got around this was by creating a symbolic link to my maven repository and pointing it to something like "c:\r". then i added the following to my settings.xml file:

<localrepository>c:\r</localrepository>

the maven repository path was contributing to the length problems in my windows machine.

score:8

answering my own question here so that the solution doesn't get buried in comments. i exported the project as a runnable jar from within eclipse and did a command line "java -jar myjar.jar" and it works perfectly fine

score:16

i was running into this issue trying to execute a jpql query in the hibernate / jpa console of intellij 2020.2

adding this to my .idea/workspace.xml fixed it

<component name="propertiescomponent">
 
...
     <property name="dynamic.classpath" value="true"/>
 
...
 
</component>

origin of the solution: https://youtrack.jetbrains.com/issue/idea-166929?_ga=2.167622078.1290412178.1604511702-23036228.1574844686

score:18

**enter image description here**

in intellij there is an option to 'shorten command line', select 'jar manifest' or '@argfiles' would solve the problem, basically it will put your lengthy class path into a jar file or a temp file

score:20

if you create your own build file rather than using project -> generate javadocs you can add useexternalfile="yes" to the javadoc task, which is designed specifically to solve this problem.

score:20

i faced this problem today and i was able to solve it using this gradle plugin

it's github url is this

if you, like me, have no idea what gradle is but need to run a backend to do your front end work, what you need to do is find the build.gradle file that is being called to start your be server and add this to the top:

plugins {
  id "ua.eshepelyuk.manifestclasspath" version "1.0.0"
}

Related Query

More Query from same tag