双击运行 Java 应用程序

发布于 2024-10-07 09:47:38 字数 75 浏览 6 评论 0原文

为什么我无法双击运行我的 java 编译的应用程序? 我的应用程序只是在cmd中运行(java -jar:我的app.jar) 请帮助我

why i can`t run my java compiled applications with double click?
my applicatins just run in cmd (java -jar: my app.jar)
plz help me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

阳光①夏 2024-10-14 09:47:38

您可以创建一个批处理文件来运行您的命令。这样它就可以工作而无需与 .jar 文件关联。如果它是 Windows 应用程序,则使用 javaw.exe 启动它。

You can make a batch file to run your command. This way it will work without the need to make associations to .jar files. If it is a windows app then start it with javaw.exe.

假装爱人 2024-10-14 09:47:38

您需要将 .jar 扩展名与 javaw.exe 关联起来,然后双击该 jar 文件时将不会显示控制台窗口

这通常是由 JDK/JRE 安装程序完成的,所以您要么没有没有正确安装 JDK,或者您手动更改了该关联。

You need to associate the .jar extension with javaw.exe, then no console window will be shown, when you double click the jar file

This is usually done by the JDK/JRE installer, so either you didn't install the JDK properly, or you manually changed that associaten.

一曲爱恨情仇 2024-10-14 09:47:38

我认为这里所有的答案都是有效的。但如果您想要在 Windows 中获得真正的可执行文件,那么您需要创建一个启动器。在 Windows 中,jar 文件不可执行。但exe文件是。有很多工具可以将所有 Java 代码包装在某个本机库中。我推荐 http://launch4j.sourceforge.net/ 我认为这就是您正在寻找的。您可以轻松创建带有图标和更多功能的可执行文件。

I think all the answer here are valid. But if you want a true executable file in Windows then you need to create a launcher. In windows, jar files are not executable. But exe files are. There are many tools out there than wrap all your java code around some native library. I recommend http://launch4j.sourceforge.net/ I think this is what you are looking for. You can easily create executable with icons and many more features.

素衣风尘叹 2024-10-14 09:47:38

您可以创建 .jar 文件的 Windows 快捷方式。

以下行可能是 Windows 快捷方式的目标。

%windir%\system32\javaw.exe -Xms1m -Xmx1m -jar "C:\Program Files\Jar Directory\file.jar"

这样做的优点是允许您指定所需的 javaw 参数,以及所需的 Windows 参数(正常窗口、最大化、在目录中启动)。

You can create a Windows shortcut to your .jar file.

The following line could be the target of the Windows shortcut.

%windir%\system32\javaw.exe -Xms1m -Xmx1m -jar "C:\Program Files\Jar Directory\file.jar"

This has the advantage of allowing you to specify the javaw parameters that you want, as well as the Windows parameters (normal window, maximized, start in directory) that you want.

我做我的改变 2024-10-14 09:47:38

只需分配要由 javaw.exe 执行的 .jar 文件即可。您可以使用 .jar 文件上的打开方式 对话框来执行此操作。

顺便说一句,Java 安装程序没有为您执行此操作吗?

Just assign .jar files to be executed by javaw.exe. You can do that using the Open with dialog on a .jar file.

BTW, doesn't the Java installer do that for you?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文