简体   繁体   English

修复错误:找不到带有jar的主类

[英]Fixing Error: cannot find main class with jar

My java game (built using lwjgl and Eclipse) won't run after being exported as a Runnable jar from Eclipse. 我的Java游戏(使用lwjgl和Eclipse构建)在从Eclipse导出为Runnable jar后将无法运行。 The program runs fine within Eclipse, and the exported jar has the correct Manifest file format. 该程序可以在Eclipse中正常运行,并且导出的jar具有正确的Manifest文件格式。 After executing this Jar, it gave me an error: 执行完这个Jar之后,它给了我一个错误:

C:\\Users\\7rent\\Desktop>java -jar hw.jar C:\\ Users \\ 7rent \\ Desktop> java -jar hw.jar

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:95)
at org.lwjgl.Sys.<clinit>(Sys.java:112)
at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:39)
at java.security.AccessController.doPrivileged(Native Method)
at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:36)
at core.SecDef.main(SecDef.java:13)
... 5 more

I then (using Stack overflow answers) used JarSplice to add the lwjgl jar and natives to this Jar. 然后,我(使用堆栈溢出答案)使用JarSplice将lwjgl jar和本机添加到此Jar中。 The resulting fatjar gives me this: 产生的fatjar给了我这个:

C:\\Users\\7rent\\Desktop>java -jar SD.jar C:\\ Users \\ 7rent \\ Desktop> java -jar SD.jar

Error: Could not find or load main class core.SecDef 错误:找不到或加载主类核心。SecDef

The manifest of the jar contains this: https://i.stack.imgur.com/ccpOH.png 罐子的清单包含以下内容: https : //i.stack.imgur.com/ccpOH.png

and the inside of the FatJar looks like this: https://i.stack.imgur.com/hVBcD.png FatJar的内部看起来像这样: https : //i.stack.imgur.com/hVBcD.png

I installed the JRE and JDK today, both latest versions with no configuration done to system variables. 我今天安装了JRE和JDK,这两个都是最新版本,没有对系统变量进行任何配置。 The project is set to be in compliance with java 6. 该项目设置为符合Java 6。

Thanks in advance :) 提前致谢 :)

The reason is given in the exception stack trace: 原因在异常堆栈跟踪中给出:

Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path 引起原因:java.lang.UnsatisfiedLinkError:java.library.path中没有lwjgl

The JVM didn't find the lwjgl native library. JVM找不到lwjgl本机库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM