First Gradle / JOGL项目遇到麻烦

时间:2016-02-22 03:16:19

标签: java eclipse gradle graphics jogl

我首先要说的是我不是要求家庭作业的答案,但我 AM 请求帮助在Eclipse中设置它。我在计算机图形学课程中,我们已经使用Gradle构建工具和JOGL绘图分配了我们的第一个作业。分配它的教授不使用IDE,所以他说如果我们想在像Eclipse这样的IDE中运行/编译,我们就是自己的。我们获得了一个带有Gradle构建的zip文件,其中包含一些示例类以及我们必须修改并返回的“作业”文件。教授包含了一些关于如何从命令行构建解决方案的简单说明,以及当我这样做时,我可以从创建的.bat文件中获取示例代码,但是在将文件作为Gradle项目导入Eclipse并尝试运行它后,我一直收到错误:

Catched FileNotFoundException: C:\Users\ktbis_000\.gradle\caches\modules-2\files-2.1\org.jogamp.gluegen\gluegen-rt\2.1.5-01\f8d80652bb29eb2b9012fbafe1c160ba80775c\gluegen-rt-2.1.5-01-natives-windows-amd64.jar (The system cannot find the file specified), while addNativeJarLibsImpl(classFromJavaJar class com.jogamp.common.os.Platform, classJarURI jar:file:/C:/Users/ktbis_000/.gradle/caches/modules-2/files-2.1/org.jogamp.gluegen/gluegen-rt/2.1.5-01/f8d80652bb29eb2b9012fbafe1c160ba80775c/gluegen-rt-2.1.5-01.jar!/com/jogamp/common/os/Platform.class, nativeJarBaseName gluegen-rt-2.1.5-01-natives-windows-amd64.jar): [ file:/C:/Users/ktbis_000/.gradle/caches/modules-2/files-2.1/org.jogamp.gluegen/gluegen-rt/2.1.5-01/f8d80652bb29eb2b9012fbafe1c160ba80775c/gluegen-rt-2.1.5-01.jar -> file:/C:/Users/ktbis_000/.gradle/caches/modules-2/files-2.1/org.jogamp.gluegen/gluegen-rt/2.1.5-01/f8d80652bb29eb2b9012fbafe1c160ba80775c/ ] + gluegen-rt-2.1.5-01-natives-windows-amd64.jar -> slim: jar:file:/C:/Users/ktbis_000/.gradle/caches/modules-2/files-2.1/org.jogamp.gluegen/gluegen-rt/2.1.5-01/f8d80652bb29eb2b9012fbafe1c160ba80775c/gluegen-rt-2.1.5-01-natives-windows-amd64.jar!/
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\ktbis_000\Desktop\Computer Graphics\Homework 2\homework02\homework02\Build\ou-cs-cg\gluegen-rt.dll
  at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
  at java.lang.Runtime.load0(Runtime.java:809)
  at java.lang.System.load(System.java:1086)
  at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:551)
  at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64)
  at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:96)
  at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:414)
  at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:388)
  at com.jogamp.common.os.Platform$1.run(Platform.java:209)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.jogamp.common.os.Platform.<clinit>(Platform.java:179)
  at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:83)
  at edu.ou.cs.cg.homework.Homework02.main(Homework02.java:67)

我已经尝试了解决方案here,创建了一个单独的JOGL项目来包含gluegen-rt.jar和jogl-all.jar,并使我的作业项目依赖于它,但我仍然不能获取要运行的代码。导入时我错过了什么吗?这是我能想到它将从.bat文件运行而不是从Eclipse运行的唯一原因。

感谢您的帮助。

编辑:这是提供给我们的build.gradle文件。我省略了包含教授个人信息的评论的一小部分。

        //******************************************************************************
//******************************************************************************
// Last modified: Tue Feb  9 20:35:55 2016 by 
//******************************************************************************
// Major Modification History:
//
// 20160209 []: Original file.
//
//******************************************************************************
// Notes:
//
// To compile on the command line
// 1. Go to the directory that contains build.gradle
// 2. Run "gradle installDist"
//
// To run on the command line
// 1. Go to directory build/install/graphics/bin
// 2. Run the script for the class you want (./foo or double-click the icon).
//
//******************************************************************************
// COMMANDS:
//
// See all available tasks in the terminal, or in a window:
// gradle -q tasks --all
// gradle --gui
//
// Scrub all build results (doesn't remove .gradle cache in home directory):
// gradle clean
//
// Generate javadoc for all subprojects:
// gradle javadoc
//
// Bundle into command line applications, or a zip file containing them:
// gradle installDist
// gradle distZip
//
//******************************************************************************

buildscript
{
    repositories
    {
        mavenCentral()
    }
}

//******************************************************************************

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'application'
apply plugin: 'eclipse'

//******************************************************************************

// Adapted from http://stackoverflow.com/questions/18421857/
// See also http://stackoverflow.com/questions/21241767/
//
// Creates scripts for entry points
// Subproject must apply application plugin to be able to call this method.
def createScript(project, mainClass, name, jvmOpts) {
  project.tasks.create(name: name, type: CreateStartScripts) {
    applicationName = name
    mainClassName   = mainClass
    defaultJvmOpts  = jvmOpts
    outputDir       = new File(project.buildDir, 'scripts')
    classpath       = project.tasks[JavaPlugin.JAR_TASK_NAME].outputs.files +     project.configurations.runtime
  }
  project.tasks[name].dependsOn(project.jar)

  project.applicationDistribution.with {
    into("bin") {
      from(project.tasks[name])
      fileMode = 0755
    }
  }
}

//******************************************************************************

   sourceCompatibility = 1.6

group = "edu.ou.cs.cg"
version = '1.1.0'

applicationName = "template"
mainClassName = "edu.ou.cs.cg.example.Template"
applicationDefaultJvmArgs = ['-Xms128m', '-Xmx756m', '-noclassgc',\
 '-Dfile.encoding=utf-8', '-Dapple.laf.useScreenMenuBar=false',\
 '-Dapple.awt.showGrowBox=true', '-Dapple.awt.brushMetalLook=false',\
 '-Dapple.awt.antialiasing=on', '-Dapple.awt.graphics.UseQuartz=true', ]

//******************************************************************************
// Alternative Start Scripts
//******************************************************************************

def altJvmArgs = ['-Xms128m', '-Xmx768m', '-noclassgc',\
 '-Dfile.encoding=utf-8', '-Dapple.laf.useScreenMenuBar=false',\
 '-Dapple.awt.showGrowBox=true', '-Dapple.awt.brushMetalLook=false',\
 '-Dapple.awt.antialiasing=on', '-Dapple.awt.graphics.UseQuartz=true', ]

// Create scripts for alternate entry points (main() methods)
createScript(project, 'edu.ou.cs.cg.example.Gasket', 'gasket', altJvmArgs)
//createScript(project, 'edu.ou.cs.cg.example.Lorenz', 'lorenz', altJvmArgs)

// You'll need to add more of these for future assignments. For each one, put
// the fully qualified classname of the class with main() in the second argument
// and the desired program name in the third argument.
createScript(project, 'edu.ou.cs.cg.homework.Homework02', 'hw02', altJvmArgs)
//createScript(project, 'edu.ou.cs.cg.homework.Homework03', 'hw03', altJvmArgs)
//createScript(project, 'edu.ou.cs.cg.homework.Homework04', 'hw04', altJvmArgs)
//createScript(project, 'edu.ou.cs.cg.homework.Homework05', 'hw05', altJvmArgs)

//******************************************************************************
// Source Sets
//******************************************************************************

sourceSets
{
    main
    {
        resources
        {
            srcDir 'src/main/java'
            //include ".*.rsrc"
            exclude "**/.DS_Store", "**/*.java.*"
        }
    }
}

//******************************************************************************
// Tasks
 //******************************************************************************

jar
{
    manifest
    {
        attributes\
            'Implementation-Title': 'ou-cs-cg',\
            'Implementation-Version': version,\
            'Main-Class': mainClassName

            manifest.attributes provider: 'tribe7.net'
            manifest.attributes permissions: 'all-permissions'
            manifest.attributes codebase: '*'
    }
}

javadoc
{
    maxMemory '756m'
}

// Hack to use alternative maximum stack and heap sizes in Windows start     scripts.
// There are probably more elegant ways to do this in recent versions of Gradle.
// Note: This only affects primary scripts, not those using our createScript().
startScripts
{
    doLast
    {
        // Windows script file
        def wsf = file getWindowsScript()
        //wsf.text = wsf.text.replace("-Xms1g", "-Xms256m")
        //wsf.text = wsf.text.replace("-Xmx2g", "-Xmx1280m")
    }
}

//******************************************************************************
// Dependencies
//******************************************************************************

repositories
{
    mavenLocal()
    mavenCentral()
}

dependencies
{
     //**********************************************************************
     //REMOTE
    //**********************************************************************

    //runtime ('colt:colt:1.2.0') { transitive = false }

    //runtime ('com.vividsolutions:jts:1.13') { transitive = false }

    compile ('org.jogamp.jogl:jogl-all-main:2.1.5-01') { transitive = true }
    compile ('org.jogamp.gluegen:gluegen-rt-main:2.1.5-01') { transitive = true     }
}

//******************************************************************************

0 个答案:

没有答案