Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 爪哇8至11;使用eclipse导出jar问题_Java_Eclipse_Java 8_Executable Jar_Java 11 - Fatal编程技术网

Java 爪哇8至11;使用eclipse导出jar问题

Java 爪哇8至11;使用eclipse导出jar问题,java,eclipse,java-8,executable-jar,java-11,Java,Eclipse,Java 8,Executable Jar,Java 11,我最近开始在游戏中使用jdk11,当我导出到一个可运行的jar时,jar中没有我放在build.gradle文件中的依赖项。 切换回jdk8解决了这个问题。我怎样才能解决这个问题?另外,当您通过eclipse导出时,为什么它适用于8而不是11 我的项目是一个gradle项目,手动向项目设置添加依赖项,因为外部JAR似乎可以工作,但我不想这样做 目前正在使用Eclipse2020-09版本 build.gradle: apply plugin: "java" sourceCo

我最近开始在游戏中使用jdk11,当我导出到一个可运行的jar时,jar中没有我放在build.gradle文件中的依赖项。 切换回jdk8解决了这个问题。我怎样才能解决这个问题?另外,当您通过eclipse导出时,为什么它适用于8而不是11

我的项目是一个gradle项目,手动向项目设置添加依赖项,因为外部JAR似乎可以工作,但我不想这样做

目前正在使用Eclipse2020-09版本

build.gradle:

apply plugin: "java"

sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/", "../client-core/assets/" ]

project.ext.mainClassName = "com.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../client-core/assets");

task run(dependsOn: classes, type: JavaExec) {
    main = project.mainClassName
    classpath = sourceSets.main.runtimeClasspath
    standardInput = System.in
    workingDir = project.assetsDir
    ignoreExitValue = true
}

task debug(dependsOn: classes, type: JavaExec) {
    main = project.mainClassName
    classpath = sourceSets.main.runtimeClasspath
    standardInput = System.in
    workingDir = project.assetsDir
    ignoreExitValue = true
    debug = true
}

task dist(dependsOn: classes, type: Jar) {
    from files(sourceSets.main.output.classesDirs)
    from files(sourceSets.main.output.resourcesDir)
    from {configurations.compile.collect {zipTree(it)}}
    from files(project.assetsDir);
 
    manifest {
        attributes 'Main-Class': project.mainClassName
    }
}
// TODO. dist still generates a small jar with "build", and the full jar with "release".
// it should generate no jar unless called directly with release.

eclipse {
    project {
        name = "client-launcher"
        linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/client-core/assets'
    }
}

task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
  doLast {
    def classpath = new XmlParser().parse(file(".classpath"))
    new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
    def writer = new FileWriter(file(".classpath"))
    def printer = new XmlNodePrinter(new PrintWriter(writer))
    printer.setPreserveWhitespace(true)
    printer.print(classpath)
  }
}

试着在你的成绩中加入与maven assembly插件相当的插件。默认打包仅打包已编译的类文件。

尝试在你的成绩中包含等效的maven assembly插件。默认打包仅打包已编译的类文件。

但为什么它适用于java 8而不是11?为什么它适用于java 8而不是11?从{configurations.compile.collect{it.isDirectory()?it:zipTree(it)}添加
jar{manifest{attributes“Main class”:“your Main class”}
在build.gradle文件中,运行clean/build。一个jar将出现在\build\libs文件夹中。这是您的可运行jar。我会尝试一下,但从eclipse导出时它为什么与jdk8而不是jdk11一起工作?从{configurations.compile.collect{it.isDirectory()添加
jar{manifest{attributes“Main Class”:“您的主类”}?it:zipTree(it)}
在build.gradle文件中运行clean/build。jar会出现在\build\libs文件夹中。这是您的可运行jar。我会尝试一下,但从eclipse导出时它为什么与jdk8而不是jdk11一起工作?