我在我的一个项目上实现了Gradle。我将Netbeans 8.02与gradle插件一起使用。
结构按原样,源代码位于jgli/src/main/java/
下,参考资料位于jgli/src/main/resources/
主类是jgli/src/Main/java/test/Main。java
如果我通过ide运行它,它在windows上运行,在linux上崩溃。这就是我现在试图通过控制台运行它的原因:
java-jarjgli.jar
但我一直得到:
错误:找不到或加载主类的测试。主要的
这是我的构建。渐变
apply plugin: 'java'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
repositories {
mavenCentral()
// You may define additional repositories, or even remove "mavenCentral()".
// Read more about repositories here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}
dependencies {
// TODO: Add dependencies here ...
// You can read more about how to add dependency here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
testCompile group: 'junit', name: 'junit', version: '4.10'
compile 'org.jogamp.jogl:jogl-all-main:2.3.2'
compile 'org.jogamp.jogl:nativewindow-main:2.3.2'
compile 'org.jogamp.jogl:newt-main:2.3.2'
compile 'org.jogamp.gluegen:gluegen-rt-main:2.3.2'
}
jar {
manifest {
attributes 'Main-Class': 'test.Main'
}
}
我刚刚修改了dependecies
部分并添加了清单部分。
我试图添加'test。Main'
到ext.main类,但它什么也没改变。.
在这里您可以下载jar。
这是我的清单。MF
:
Manifest-Version: 1.0
Main-Class: test.Main
Main.class正确地位于罐子内。Main.java有包声明包测试;
也试过
apply plugin: 'application'
mainClassName = 'test.Main'
没有成功...
我错过了什么?
通常,在生成文件中设置主类,如下所示:
mainClassName = 'package.MainClassName'
你把它作为参数传递吗?-
我刚刚找到了你的git仓库和你的Main类的来源,似乎它实现了一些接口,这是在你的依赖关系中提供的:
import com.jogamp.newt.event.KeyListener;
import com.jogamp.opengl.util.GLEventListener;
public class Main implements GLEventListener, KeyListener {
...
它们来自您的一些依赖项库:
compile 'org.jogamp.jogl:jogl-all-main:2.3.2'
compile 'org.jogamp.jogl:nativewindow-main:2.3.2'
compile 'org.jogamp.jogl:newt-main:2.3.2'
compile 'org.jogamp.gluegen:gluegen-rt-main:2.3.2'
在这种情况下,在运行主类时,依赖项必须位于类路径中。尝试提供-cp
选项以指向可以找到依赖项的路径。
问题内容: 我正在尝试使用Gradle运行一个非常简单的项目,并在使用时遇到以下错误: 这是我的文件结构: 我排除了libs和tmp文件夹的内容,因为我认为这与该问题无关,但是我可以在需要时添加它。 这是我的build.gradle文件: 关于如何解决此问题的任何想法?我已经为mainClassName属性尝试了各种方法,但似乎没有任何效果。 问题答案: 我在这里看到两个问题,一个与另一个有关。
问题内容: 我想连接我的java程序以连接数据库并检索数据。它的编译完美,但运行时即时得到这个 我已经安装了Java SQL驱动程序,并将jar路径作为CLASSPATH添加到环境变量中 问题答案: 您应该从这里下载驱动程序 和JAR文件需要添加到项目类路径。 首先,右键单击Eclipse Project,然后单击Project-> Build Path-> Configure Build Pat
当我正常运行此代码时,它会吐出: 异常线程"main"java.lang.ClassNotFoundExcture: bookReader 在java.net.URLClassLoader.find类(URLClassLoader.java:381) 在java.lang.ClassLoader.load类(ClassLoader.java:424)<在sun.misc.启动$AppClassLo
项目结构为: build.gradle就像: gradle build-很好用 gradle运行-抛出错误"找不到或加载主类"
我试图复制Spring Boot Kotlin示例项目https://github.com/jetbrains/kotlin-examples/tree/master/tutorials/spring-boot-restful。我添加了更多的依赖项,当我试图构建可执行jar并运行它时,我得到了错误:
问题内容: 我在笔记本电脑上有一个日食项目,我将其推送到Git https://github.com/chrisbramm/LastFM-History-Graph.git 它可以完全在我的笔记本电脑上运行,并且可以正常运行/构建,但是在我的台式机上,Eclipse没有显示错误 错误:找不到或加载主类lastfmhistoryguis.InputPanel 我尝试从以下位置构建项目: 但是什么也没
此依赖项导致Eclipse Juno在pom.xml上给出一个红色十字标记,并在
我使用的是Java Maven程序,我不知道输入什么作为