生成的Runnable jar:找不到主类 [英] Generated Runnable jar: Could not find the main class
问题描述
我一直使用Eclipse的Export-> Runnable jar选项,它运行良好,但是今天看来,我创建的所有Runnable jar都会在运行时产生以下错误:(双击文件即可运行它们.)
I've always used the Export -> Runnable jar option of Eclipse and it has worked perfectly, but today it seems that all the Runnable jars I create produce the following error when I run them: ( run them by double clicking the file.)
Java虚拟机启动器
找不到主类:(类).程序将退出.
在过去的两个小时中,我已经尝试了所有方法,但仍然无法正常工作.
I've tried everything for the past two hours, but it still doesn't work.
- 我仍然可以运行过去创建的jar,而无需问题.
- 清单文件看起来与这些罐子中的文件完全相同工作正常,所有
.class
文件似乎都在适当的位置... - 我尝试使用
将所需的库打包到生成的jar
中导出,但是该文件仍然无法正常工作.虽然它没有显示错误-双击文件没有任何作用.
- I can still run jars that I have created in the past without a problem.
- The manifest file looks exactly the same as in those jars
that work and all the
.class
files seem to be in place... - I've tried exporting with
Package required libraries into generated jar
but the file still doesn't work. It doesn't show the error though - double clicking the file does nothing.
编辑:通过 cmd
运行jar文件非常有效,但是只需双击它就会产生此错误.(盗贼)
Edit: Running the jar file through the cmd
works perfectly, but simply double clicking on it yields this error. (Bragboy)
修改2:可以正常工作的jar中的清单文件的内容:(显然它们是相同的,只是为了避免混淆.)
Edit 2: Contents of a manifest file from a jar that works: (Obviously they're the same, just wanted to avoid confusion.)
清单版本:1.0
类路径:.
主类:defender.DefenderComponent(之后加上两个空行)
Manifest-Version: 1.0
Class-Path: .
Main-Class: defender.DefenderComponent (+ two empty lines afterwards)
和来自jar的清单文件的内容不起作用:(直接打开文件时)
And contents of a manifest file from a jar that doesn't work: (When opening the file directly)
清单版本:1.0
类路径:.
主要类别:pixel.Entry(+ 2个空行)
Manifest-Version: 1.0
Class-Path: .
Main-Class: pixel.Entry (+ two empty lines afterwards)
两个主类文件都位于各自的位置.
Both main class files are confirmed to be at their respective locations.
推荐答案
最后,唯一解决此问题的方法是从JRE 1.7切换到JRE 1.6.
In the end the only thing that fixed this was to switch from JRE 1.7 down to JRE 1.6.
这篇关于生成的Runnable jar:找不到主类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!