简体   繁体   English

jar文件未执行

[英]jar file doesn't execute

I'm trying to execute jar file of netbeans swing small project. 我正在尝试执行netbeans swing小项目的jar文件。 The file isn't executing. 该文件未执行。 I need to make it work by double clicking on the jar file that is located in: 我需要双击位于以下位置的jar文件使其工作:

C:\Users\armyTik\Documents\NetBeansProjects\Notepad\dist\Notepad.jar

extra details: 额外的细节:

properties -> Build -> Packaging -> "Build JAR after compiling" and "Copy Dependent Libraries" are checked. 属性->构建->包装->“编译后构建JAR”和“复制依赖库”已选中。

properties -> run -> Main class: "notepad.NotepadComponent" 属性->运行->主类:“ notepad.NotepadComponent”

In the cmd, by manually executing the jar file I get the following error: 在cmd中,通过手动执行jar文件,我得到以下错误:

cd C:\Users\armyTik\Documents\NetBeansProjects\Notepad\dist
java -jar Notepad.jar
"Error: Could not find or load main class notepad.Notepad"

What should I do, specifically? 我该怎么办,特别是?


EDIT: 编辑:

I extracted the jar file and got: 我提取了jar文件并得到:

META-INF/MANIFEST.MF
notepad/FileManager.class
notepad/icon.gif
notepad/NotepadComponent$1.class
notepad/NotepadComponent$2.class
notepad/NotepadComponent$3.class
notepad/NotepadComponent$4.class
notepad/NotepadComponent$5.class
notepad/NotepadComponent$6.class
notepad/NotepadComponent$7.class
notepad/NotepadComponent.class
notepad/Thumbs.db

META-INF/MANIFEST.MF content: META-INF / MANIFEST.MF内容:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.4
Created-By: 1.8.0_102-b14 (Oracle Corporation)
Class-Path: 
X-COMMENT: Main-Class will be added automatically by build
Main-Class: notepad.NotepadComponent

Update2: 更新2:

I got new exception while trying to open the jar from the cmd: 尝试从cmd打开jar时出现新异常:

While opening the project from netbeans, the icon is shown with no exception. 从netbeans打开项目时,图标无一例外地显示。 *****When I remove the icons , The jar is working! *****当我删除图标时,广口瓶正在工作! but I need to keep the icons in the application. 但是我需要将图标保留在应用程序中。

在此处输入图片说明

This is because your classpath is not correct. 这是因为您的类路径不正确。 Try it like this: 像这样尝试:

java -cp "<PATH>/Notepad.jar" notepad.Notepad

If this does not work then unpack the jar file and confirm the package and class name is correct, Print CLASSPATH env variable or check java and javac versions. 如果这不起作用,请解压缩jar文件并确认包和类名正确,然后打印CLASSPATH env变量或检查java和javac版本。

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

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