Java 创建进程错误=206;文件名或扩展名太长

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26730838/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 03:11:19  来源:igfitidea点击:

Createprocess error=206; the filename or extension is too long

javaeclipsemavengwtbirt

提问by ahlexander

I know this question has been asked before, but I wasn't able to fix it using solutions from other posts. I'm trying to compile a complex hierarchy of gwt projects using maven. Everything worked fine until I had to add one more library, more specifically: org.eclipse.birt.runtime

我知道之前有人问过这个问题,但我无法使用其他帖子中的解决方案来解决它。我正在尝试使用 maven 编译一个复杂的 gwt 项目层次结构。一切正常,直到我不得不再添加一个库,更具体地说:org.eclipse.birt.runtime

Now I get this error:

现在我收到这个错误:

[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.6.1:debug ....

..... [Lots of jars, many containing birt, no duplicates though] .....


Error while executing process. Cannot run program "C:\Program Files\Java\jdk1.8.0_20\jre\bin\java": CreateProcess error=206, The filename or extension is too long

The dependency I'm using is:

我正在使用的依赖项是:

<dependency>
    <groupId>org.eclipse.birt.runtime</groupId>
    <artifactId>org.eclipse.birt.runtime</artifactId>
    <version>4.4.1</version>
</dependency>

采纳答案by ahlexander

I finally managed to solve it:

我终于设法解决了它:

Turns out birt, together with its dependencies, was simply adding too many libraries and the classpath became too long for windows command to handle. Furthermore, birt libraries have stupidly long names.

结果证明 birt 及其依赖项只是添加了太多的库,并且类路径变得太长,windows 命令无法处理。此外,birt 库的名称非常长。

Solved it using this dependency (I only needed the runtime), I created the lib and birt directories and placed the jar there myself:

使用此依赖项解决了它(我只需要运行时),我创建了 lib 和 birt 目录并自己将 jar 放在那里:

<dependency>
    <groupId>org.eclipse.birt.runtime</groupId>
    <artifactId>org.eclipse.birt.runtime</artifactId>
    <version>4.4.1</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/birt/birt.runtime-4.4.1.jar</systemPath>
</dependency>

回答by Thomas Broyer

Birt has no reason to be in the classpath if it's not used client-side.

如果没有在客户端使用,Birt 没有理由在类路径中。

Unfortunately, Maven sometimes makes things harder than necessary; so with Maven you need your GWT client code to be a specific Maven module with no dependency on server-side code; then "merge" everything into a single WAR using WAR overlays.

不幸的是,Maven 有时会使事情变得比必要的困难。因此,对于 Maven,您需要 GWT 客户端代码是一个特定的 Maven 模块,不依赖于服务器端代码;然后使用 WAR 覆盖将所有内容“合并”到单个 WAR 中。

With that layout (let's call the modules app-clientand app-server), you have several solutions to launch gwt:runor gwt:debug:

使用该布局(让我们将模块app-client和称为app-server),您有多种解决方案可以启动gwt:rungwt:debug

  • never tried but you could probably configure hostedWebappto point to your app-serveroutput directory:

    <hostedWebapp>../app-server/target/app-server-${project.version}/</hostedWebapp>
    

    Make sure you run mvn cleanbefore packaging your app-serverWAR though to be sure the generated JS files come from app-client(as a WAR overlay) and not app-server(generated by gwt:run)

  • what I use in gwt-maven-archetypes: launch the server-side code in a distinct servlet container, and use <noServer>true</noServer>

    Make sure you run mvn cleanbefore packaging too, or use -Dgwt.compiler.force, to be sure gwt:compilewon't treat the DevMode-generated *.nocache.jsfile as up-to-date and will recompile the application.

  • 从未尝试过,但您可能可以配置hostedWebapp为指向您的app-server输出目录:

    <hostedWebapp>../app-server/target/app-server-${project.version}/</hostedWebapp>
    

    确保mvn clean在打包app-serverWAR之前运行,但要确保生成的 JS 文件来自app-client(作为 WAR 覆盖)而不是app-server(由 生成gwt:run

  • 我在gwt-maven-archetypes 中使用的内容:在不同的 servlet 容器中启动服务器端代码,并使用<noServer>true</noServer>

    确保mvn clean在打包前也运行,或使用-Dgwt.compiler.force,以确保gwt:compile不会将 DevMode 生成的*.nocache.js文件视为最新文件并重新编译应用程序。