ele*_*ect 8 java program-entry-point find gradle netbeans-8
我在我的一个项目上实现了Gradle .我使用带有gradle插件的Netbeans 8.02.
结构是应该的,源位于jgli/src/main/java/,资源下jgli/src/main/resources/
主类是 jgli/src/main/java/test/Main.java
如果我通过ide运行它,它在Windows 上运行,它在linux 上崩溃.这就是为什么我现在试图通过控制台运行它:
java -jar jgli.jar
但我一直在:
错误无法找到或加载主类'test.Main'
这是我的 build.gradle
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'
}
}
Run Code Online (Sandbox Code Playgroud)
我刚刚修改了dependecies部分并添加了清单部分.
我试图添加'test.Main'到ext.mainClass,但它没有改变任何东西..
在这里你可以下载jar.
这是我的MANIFEST.MF:
Manifest-Version: 1.0
Main-Class: test.Main
Run Code Online (Sandbox Code Playgroud)
Main.class正确位于jar内.Main.java有包声明package test;
也试过
apply plugin: 'application'
mainClassName = 'test.Main'
Run Code Online (Sandbox Code Playgroud)
没有成功..
我错过了什么?
我刚刚找到你的 git存储库和Main 类的来源,似乎它实现了一些接口,该接口在你的依赖项中提供:
import com.jogamp.newt.event.KeyListener;
import com.jogamp.opengl.util.GLEventListener;
public class Main implements GLEventListener, KeyListener {
...
Run Code Online (Sandbox Code Playgroud)
它们来自您的一些依赖库:
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'
Run Code Online (Sandbox Code Playgroud)
在这种情况下,当您运行 Main 类时,您的依赖项必须位于您的类路径中。尝试提供-cp指向路径的选项,可以在其中找到您的依赖项。
| 归档时间: |
|
| 查看次数: |
9552 次 |
| 最近记录: |