简体   繁体   English

我无法运行 JAR 文件?

[英]I can't run JAR file?

I have created a Java JAR file in NetBeans. I have already run clean and build on the program and everything was successful.我在 NetBeans 中创建了一个 Java JAR 文件。我已经运行干净并在程序上构建,一切都成功了。 When I run the program in NetBeans is also successful, but when i locate the JAR file in the NetBeans dist folder and run it, nothing happens.当我运行NetBeans中的程序时也成功了,但是当我在NetBeans dist文件夹中找到JAR文件并运行它时,没有任何反应。 The program doesn't run, and there are no exceptions or messages.该程序不运行,并且没有异常或消息。 Could you please help me understand why.你能帮我理解为什么吗?

EDIT: I already solved the problem.编辑:我已经解决了这个问题。

Are you trying to make executable jar?您是否要制作可执行文件 jar? You might wanna put your main class in manifest of the jar file.您可能想将主要的 class 放在 jar 文件的清单中。

Something like:就像是:

Main-Class : file_name_with_main_method

It sounds like you're probably on Windows:)听起来你可能在 Windows:)

One way to "run" a.jar file is to create a Windows File association for ".jar" suffix and the "javaw.exe" command: “运行”a.jar 文件的一种方法是为“.jar”后缀和“javaw.exe”命令创建一个 Windows 文件关联:

1) Go into Windows Explorer and [Browse...] to your.jar file 1) Go 到 Windows Explorer 和 [Browse...] 到你的.jar 文件

2) Right-click the.jar file, and select the "open with..." option. 2)右击.jar文件,select“打开方式...”选项。

3) Select javaw.exe as above, and see if it runs. 3)如上Select javaw.exe,看是否运行。

I would suggest checking the Console if you are on a Mac.如果您使用的是 Mac,我建议您检查控制台。 You can view errors from the Jar launch to understand why it failed.您可以查看 Jar 启动的错误以了解失败的原因。

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

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