我正在使用
gradle
将一些Java代码打包到jar中。我在用一些课程
tools.jar
. 我在
年级学生
构建它并制作一个jar,但是当我使用
java -jar <package>.jar
我明白了
java.lang.NoClassDefFoundError: com/sun/tools/attach/VirtualMachine
.
自从
工具罐
是你用
jdk
不是
jre
. 我有办法打包吗
工具罐
和我一起
package.jar
让我的罐子在任何地方工作?
这是我的
build.gradle
到目前为止。
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
}
description = "A java program"
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
flatDir {
dirs System.properties['java.home'] + '/../lib'
}
}
jar {
archiveName = "jProg.jar"
manifest {
attributes(
'Dependencies': 'com.sun.tools'
)
}
}
dependencies {
compile group: 'com.sun', name: 'tools'
}