Exporting jar from eclipse won't work

时间:2015-06-30 19:19:18

标签: java eclipse exception jar executable-jar

I built a Java project in eclipse. It runs fine from within eclipse. I've exported it as a jar before and it's worked fine. It's been a while since the last export, though. This time, when I exported and clicked on the jar, nothing happened.

Running it from the command line reveals the following error:

C:\>java -jar "C:\Users\Quinn\Desktop\think.jar"
Exception in thread "main" java.lang.IllegalAccessException: Class org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader can not access a member of class think.Main with modifiers "public static"

What does this error mean? Are there any reasons why this could happen? I haven't been able to find any mention of it online.

Thanks a lot.

EDIT: when I unzip the jar, the contents looks like this: enter image description here

the manifest (in META-INF) looks like this: (yes, it has an extra empty line)

Manifest-Version: 1.0
Rsrc-Class-Path: ./ substance-6.1.jar trident.jar
Class-Path: .
Rsrc-Main-Class: think.Main
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

2 个答案:

答案 0 :(得分:1)

当您使用Export>时JarRsrcLoader包含在Jar中Runnable JAR文件。它处理jar中的嵌套jar文件。

JarRsrcLoader正在尝试找到main的{​​{1}}方法,但无法找到名为think.Main的{​​{1}}方法。

答案 1 :(得分:0)

嗯,这很尴尬。事实证明,虽然我的主要方法是public static,但包含的类不是公开的。现在一切都已修好:)