0

我正在尝试使用 deeplearning4j 创建一个神经网络。我创建了一个 Maven 项目。但是当我运行这个项目时,我得到了这个 java 错误。

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project demo-neural: Command execution failed. Cannot run program "C:\Program Files\Java\jdk1.8.0_77\bin\java.exe" (in directory "C:\Users\dev1\Documents\New folder (3)\NeuralNetwork"): CreateProcess error=206, The filename or extension is too long -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

我的 pom.xml 看起来像这样

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.cdap</groupId>
    <artifactId>demo-neural</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>

    <name>A Camel Route</name>
    <url>http://www.myorganization.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>2.17.3</version>
        </dependency>
        <!-- logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.21</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.21</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-core</artifactId>
            <version>0.5.0</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>dl4j-spark_2.11</artifactId>
            <version>0.4-rc3.10</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
        </dependency>

        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-native</artifactId>
            <version>0.4-rc3.10</version>
        </dependency>
        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-api</artifactId>
            <version>0.5.0</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>canova-nd4j-common</artifactId>
            <version>0.0.0.16</version>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.11</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-mllib_2.11</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.10.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <version>2.7.2</version>
        </dependency>
        <dependency>
            <groupId>nz.ac.waikato.cms.weka</groupId>
            <artifactId>weka-stable</artifactId>
            <version>3.6.6</version>
        </dependency>
        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-native-platform</artifactId>
            <version>0.4.0</version>
        </dependency>

        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-cuda-7.5-platform</artifactId>
            <version>0.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.datavec</groupId>
            <artifactId>datavec-spark_2.10</artifactId>
            <version>0.4.0</version>
        </dependency>
        <!--<dependency>-->
        <!--<groupId>org.nd4j</groupId>-->
        <!--<artifactId>nd4j-api</artifactId>-->
        <!--<version>0.0.3</version>-->
        <!--</dependency>-->

        <!-- testing -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-test</artifactId>
            <version>2.17.3</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-nlp</artifactId>
            <version>0.0.3.3</version>
        </dependency>

        <dependency>
            <groupId>org.datavec</groupId>
            <artifactId>datavec-api</artifactId>
            <version>0.5.0</version>
        </dependency>
    </dependencies>

    <build>
        <defaultGoal>install</defaultGoal>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <!-- Allows the example to be run via 'mvn compile exec:java' -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>com.cdap.MainApp</mainClass>
                    <includePluginDependencies>false</includePluginDependencies>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

谁能帮我解决这个问题?我尝试了很多选择,但没有任何效果。提前致谢。

4

3 回答 3

0

当我使用 aws-java-sdk 库时,出现了这个错误。减少图书馆的数量对我有帮助。显然有些图书馆的名字太大了。但我只需要 aws-java-sdk-s3 所以我在 maven 中将 aws-java-sdk 替换为 aws-java-sdk-s3 并解决了问题。但是当您需要长名称的库时,这不是解决方案)

于 2017-12-19T09:06:50.457 回答
0

问题实际上在于.m2\repository文件夹中 jar 的位置。这些罐子的位置太长而无法识别。Maven 下载 jars 并将它们放在默认位于C:\Users\< your.username >\.m2\文件夹中的\repository文件夹中。

maven 当前显示的错误表明 jdk 存在问题,但事实并非如此。问题是 jdk 无法拾取一些罐子,因为它们的路径太长,jdk 无法拾取。

简单的解决方案

将您的存储库文件夹从C:\Users\< username >\.m2\repository移动到可能直接在C:\repository中的某个较短路径的位置

现在,您必须将 maven 存储库的默认路径更改为 maven 的settings.xml中的新位置。

settings.xml的默认路径是C:\maven\conf\

搜索以下行

<!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
 -->

删除评论并保留以下几行:

<localRepository>/path/to/local/repo</localRepository>

在这里放置本地存储库的路径。例如C:\repository

保存并再次使用 maven 运行。一切都应该像以前一样工作。

于 2017-10-27T09:30:34.540 回答
0

命令执行失败。无法运行程序“C:\Program Files\Java\jdk1.8.0_77\bin\java.exe”(在目录“C:\Users\dev1\Documents\New 文件夹 (3)\NeuralNetwork”中):CreateProcess 错误=206 , 文件名或扩展名太长

尝试重命名“新文件夹(3)”目录

于 2016-09-13T12:18:15.203 回答