.jar文件无法启动。

huangapple go评论83阅读模式
英文:

.jar file not getting launched

问题

我已经使用了Amazon Corretto和Java的JRE(javaw.exe)来尝试运行我的jar文件。任务管理器显示正在运行“Java Platform SE Binary”,但我的笔记本电脑上没有显示jar程序的对话框(或显示)。
我甚至尝试通过命令提示符或批处理文件来打开它,但都徒劳无功。
对任何帮助,不胜感激!谢谢!【任务管理器截图】1

英文:

I've used Amazon corretto and Java's jre(javaw.exe) to try running my jar file. The task manager says that 'Java Platform SE Binary' is running but no dialogue box(or display) of the jar program is shown on my laptop.
I even tried opening it through command prompt or through a bat file, all in vain.
Any and all help would be deeply appreciated! Thanks! Task Manager snap

答案1

得分: 1

一个 Java 应用程序执行... 与 Java 应用程序要执行的内容相符。

这可能完全不涉及 GUI。如果你尝试启动的 Java 应用程序不从 javax.swing 等包中主动涉及任何 GUI 元素,那么在 Windows 环境中你将完全注意不到任何变化。

尝试使用 java.exe - javaw.exe 不显示任何控制台输入或输出,而 java.exe 会显示。如果它是一个控制台应用程序(从命令行读取和打印文本),如果你尝试使用 javaw.exe 启动它,它将简单地看起来什么都没有发生。

例如,这个应用程序:

// 将其保存为 'Example.java'
public class Example {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

然后打开一个 '命令提示符'(运行 cmd.exe),导航到正确的目录,并运行:

javac Example.java
java Example

什么都不会发生。你将会看到你正在观察的正是你所见的(或者可能你无法看到,因为应用程序关闭得太快了。但你肯定不会看到任何窗口或文本)。然后运行:

java Example

你将会看到:Hello, World!,然后应用程序退出。

如果对于“命令行”一词感到困惑,好吧,如果你想要编程,你将不得不了解它的工作原理,但幸运的是,有很多教程可以参考 .jar文件无法启动。

英文:

A java app does.. what the java app does.

Which may well involve no GUI whatsoever. You won't notice anything whatsoever in your windows environment if the java app you're trying to start doesn't actively involve any GUI elements from e.g. the javax.swing package.

Try using java.exe - javaw.exe does not show any console input or output, whereas java.exe does. If it's a console app (that reads and prints text from the command line), it would simply appear to be doing nothing if you try to launch it with javaw.exe.

For example, this app:

// Save this as 'Example.java'
public class Example {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

then open a 'dos box' (run cmd.exe), navigate to the proper directory, and run:

javac Example.java
javaw Example

does nothing. You witness precisely what you are witnessing (or possibly you can't witness it as the app closes too fast. But you certainly won't see any windows or any text). Then run:

java Example

and you'll see: Hello, World! and then the app exits.

If 'the command line' is gobbledygook to you, well, if you want to program, you're going to have to know how it works, but, fortunately, there are plenty of tutorials around .jar文件无法启动。

huangapple
  • 本文由 发表于 2020年7月25日 21:29:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/63088946.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定