无法运行maven项目

时间:2016-09-13 12:08:51

标签: java maven recurrent-neural-network deeplearning4j

我正在尝试使用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>

任何人都可以帮我解决这个问题吗?我尝试了很多选项,没有任何效果。提前谢谢。

3 个答案:

答案 0 :(得分:0)

  

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

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

答案 1 :(得分:0)

问题实际上是在 .m2 \ repository 文件夹中的jar位置。这些罐子的位置太长,无法确定。 Maven下载jar并将它们放在默认位于 C:\ Users \&lt;中的 \ repository 文件夹中。 your.username&gt; \。m2 \ 文件夹。

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

简易解决方案

C:\ Users \&lt; 移动存储库文件夹用户名&gt; \。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:\存储库

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

答案 2 :(得分:0)

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